Hello world on a report

Post

Posted
Rating:
#1 (In Topic #369)
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
 Can someone point me to a very simple report   "Hello World" ?
No fancy data base or books …. just a simple one page Report with a line or two of text and a graphic
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
I have not played with gb.report2 before, in fact the documentation is so incomplete that even its purpose was a mystery to me.

This is how I got here: -

1/. Start a new Graphical Application
2/. Add the component gb.report2
3/. Right click on FMain > New > Report
4/. Delete FMain
5/. Make Report1 the startup class

You will then have a new Report Form to work with. I played with this to get: -

…. just a simple one page Report with a line or two of text and a graphic

No code needed to get this far. What do you want to do with it? I'd be interested to know how you get on.

<IMG src="http://www.cogier.com/gambas/Report1.png"> </IMG>

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
Thank you , I think this is exactly what I am looking for.  I am kinda new getting back to programming and am learning, I am thinking that it might be easer to do the following visually  on a report, I will report back with my progress

Also should I be converting the String array "checkingaccountdata[ ]" to a class ?

The following will print 3 check on blank check paper.


Code (gambas)

  1. Public Sub Printer1_Draw()
  2.  
  3.   Dim offset As Float
  4.  
  5.   For offset = 0 To dotsperinch * checkhight * 2 Step dotsperinch * checkhight  ' print 3 checks per page
  6.  
  7.     Paint.Font = Font["Aeral,12, Bold,italic"]
  8.     Paint.DrawRichText("<Font Color= blue>" & checkingaccountdata[custname], 3400, 300 + offset)
  9.     Paint.Font = Font["Aeral,12"]
  10.     Paint.DrawRichText(checknumber, 8000, 300 + offset)
  11.     Paint.Font = Font["Aeral, 10"]
  12.     Paint.DrawText(checkingaccountdata[custaddress], 3400, 500 + offset)
  13.     Paint.DrawText(checkingaccountdata[custaddress2], 3400, 700 + offset)
  14.     Paint.DrawrichText("Date" & String$(22, "_"), 7000, 780 + offset)
  15.     Paint.DrawrichText("<small>Pay to the<br> order of:</small>" & String$(52, "_"), 3000, 1100 + offset)
  16.     Paint.DrawrichText("<h2>$</h2>", 7800, 1160 + offset)
  17.     Paint.DrawrichText(String$(16, "_"), 8000, 1240 + offset)  ' dollar line
  18.     Paint.DrawrichText(String$(72, "_") & "<small>Dollars</small>", 3000, 1650 + offset)
  19.     Paint.DrawrichText("<small>Note</small>" & String$(22, "_"), 3000, 2400 + offset)
  20.     Paint.DrawRichText(String$(35, "_"), 6300, 2400 + offset) ' signiture line
  21.     Paint.Font = Font["Aeral, 12, italic"]
  22.     If checkingaccountdata[bankgraphic] <> "gambas.jpg" Then
  23.       Draw.Picture(PictureBox1.Picture, 3400, 1690 + offset, 2500, 500)
  24.     Else
  25.       Paint.DrawRichText(checkingaccountdata[bankname], 3400, 1900 + offset)
  26.       Paint.Font = Font["Aeral, 10"]
  27.       Paint.DrawRichText("< small >" & checkingaccountdata[bankinfo1] & "< / small >", 3400, 2100 + offset)
  28.       Paint.DrawRichText("< small >" & checkingaccountdata[bankinfo2] & "< / small >", 3400, 2250 + offset)
  29.    Endif
  30.     Paint.Font = Font["MICR Encoding,20"]
  31.     Paint.DrawText("a" & checkingaccountdata[routingnumber] & "a    " & checkingaccountdata[accountNumber] & "c   " & checknumber, 3100, 2960 + offset)
  32.    
  33.      checknumber -= numberofPages
  34.   Next
  35.   checknumber += (numberofPages * 3) - 1
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
 I'm glad it helped.

The code you provided is not complete so I could not see exactly what you are trying to do. Have you spelt the font 'Aeral' correctly, should it not be 'Arial'?

I don't see why you have to make a class for an array but again if you could upload a program we can run, that would help.
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
You are correct … spelling is not my best subject  :lol:

I looks like the report module is not going to do what I wanted, but i will keep looking at it.

I would like feedback on my program, don't be afraid to insult me, I have a thick skin.

attached is the complete program

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Guru
cogier is in the usergroup ‘Guru’
Have a look at the changes I have made in the attached program.

Changes: -
Form now fully expandable
Values can now be changed by rotating the mouse wheel.
Picture works better (Suggest you don't use 'Stretch' but the 'Mode' option instead. I updated the help on this here)
'Quit' is not recommended see here. Use 'Me.Close' instead.
I was changing the TextBox text and moving to the next with the 'Tab' key. This meant the data was not updating as I did not use the enter key. It took me sometime to work this out. I have added a routine "Update" to update the array before saving.
I have made several changes to the Load and Save routines, your 'Home' may be "mhc" but mine is not. You need to use 'User.Home' to solve this issue.
There is no need to use 'Blah & "/" & Blah' use '&/' instead it will work out if you need a "/" or not.
I hope this all helps.

<IMG src="http://www.cogier.com/gambas/BankInfo1.png"> </IMG>

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
Thank You very much for you suggestion and changes, Many of them are things I was trying to find.
I now understand what the spring does  :D
There is so much to learn between the system and the language that it is daunting for me.

I have been trying to grasp the concept of OOP … I realize that Gambas is not a true OOP language But:
If I wanted to change the String[] array to an object or class, (as a learning experience) can you suggest how to do  that and what is the syntax ?
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Regular
stevedee is in the usergroup ‘Regular’

grayghost4 said

…I have been trying to grasp the concept of OOP … If I wanted to change the String[] array to an object or class, (as a learning experience) can you suggest how to do  that and what is the syntax ?

I don't really understand your question regarding String[], so sorry if I misunderstand.

String[] is really already a class, which you can use to create a new instance of itself as an Object;

Code (gambas)

  1. Public aSomeText As String[]
  2.  
  3.   aSomeText = New String[3]   'create an instance of the String[] class with 3 elements
  4.  

So now that aSomeText is a new object based on the String[] class, you can use its properties:-

Code (gambas)

  1.  
  2.   aSomeText[0] = "BWM"
  3.   aSomeText[1] = "Chevrolet"
  4.   aSomeText[2] = "Jaguar"
  5.   Me.Text = aSomeText.Count
  6.  

…and you can use its Methods to do stuff like:-

Code (gambas)

  1.   Me.Text &= aSomeText.First  'return the first item
  2.   aSomeText.Shuffle           'shuffle the array
  3.   Me.Text &= aSomeText.First
  4.   aSomeText.Clear             'clear the array
  5.  
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Guru
cogier is in the usergroup ‘Guru’
If I wanted to change the String[] array to an object or class, (as a learning experience) can you suggest how to do that and what is the syntax ?

I'm with Steve on this as well. The interesting thing about your array is that you don't need it. I have been messing again and reduced the code considerably.

The array was storing the data in your TextBoxes and SpinBoxes, however, the TextBoxes and SpinBoxes are already storing the data so in this version instead of referring to Array[9] I have just gone to the TextBox and got the information from there.

There is no need to check if the cheque number (Sorry UK spelling) is less that 1 as the SpinBox is set not to go less that 1 (less code)

As all the TextBoxes in this program are now in a VBox a simple 'For each…' loop will get the data from each TextBox to save.

I have also put the 'Graphics' in a ComboBox to make things easier.

NOTE. The order of the saved data is in a different order than your original, the cheque number is now last.

I have tested this code and it seems to work OK but please test it yourself before putting it into use.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
 Thanks to both of you, I do appreciate the feedback and ideas.  

Looks like lot of new techniques to learn, it is time to start over with this program from scratch.
If I just take your code and use it … I have not learned anything … I have to use your suggestion and implement them myself.
This is a good learning project to learn the language and GUI
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Regular
stevedee is in the usergroup ‘Regular’

grayghost4 said

…If I just take your code and use it … I have not learned anything … I have to use your suggestion and implement them myself…

Yes, that's definitely the right attitude.
Online now: No Back to the top

Post

Posted
Rating:
#12
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
I have not been able to do what I wanted with the report module.

But with your help I have been able to finish my check program and in the process learn a lot  :)

I have posted the program again for comments and maybe someone else will learn some of the things I learned.

Thanks again to those that help !

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#13
Avatar
Guru
cogier is in the usergroup ‘Guru’
Several things you could consider.

In the program the comma is a problem as you are using it as a Split Separator, consider saving with NewLines or my favourite character for this sort of thing "`". It's on the left of the "1" key on your keyboard, I have no idea what it is designed for. So now no need to worry about commas.  :D

Code

Samplebankofamerica,Mrs. Jone Smith ,1234 Main Street      (555)123-7654,Home Town  State  Zipcode,0789000231,084332167,bankofamerica.jpg,23459
becomes

Code

Samplebankofamerica`Mrs. Jone Smith `1234 Main Street      (555)123-7654`Home Town  State  Zipcode`0789000231`084332167`bankofamerica.jpg`23459

Then use Split(Text,"`") to get your data.

If you have a load of TextBoxes, as in this case, you can give then the same Group name e.g. AllTextBoxes. This means that an event on any of the TextBoxes will be directed to one routine e.g. AllTextBoxes_Change(). You can use the Last keyword which holds all the data of the TextBox last used. Have a look at the 8 routines I have reduced to 1 in the attached.

You could use a ValueBox that only takes numbers and make the other change above and you could remove that routine as well. :D

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#14
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
thank you cogier for the feedback  I was trying to find a separator that work and the accent mark look good.
Also thanks for the hint to the use of the Group uses , but I have assinged just the number fields to "NumberBoxes" and I like the code below , I think it is easer to read and self explanatory.

Code (gambas)

  1. Public Sub NumberBoxes_keypress()  
  2.  
  3.   If IsDigit(Key.text) Then
  4.   Else If key.Code = key.BackSpace Then  'continue allow key
  5.   Else If key.Code = key.Delete Then
  6.   Else If Key.Code = Key.Left Then
  7.   Else If Key.Code = Key.Right Then
  8.   Else If Key.code = Key.Tab Then
  9.   Else
  10.     Stop Event  ' ignore all other keys
  11.  

I will try switching them to value boxes.   :D
Online now: No Back to the top
1 guest and 0 members have just viewed this.