Solved

Making A Budget Form

Posted on 2006-07-15
6
252 Views
Last Modified: 2010-04-30
Here we go,

I am trying to make a form with a budget on it.  I am trying to make it with a estimated side and an actual side.  Then I want to be able to save it as a disk file and print it to my printer.  What I am using for code somewhat does what I want for the budget but I need better.  Here is my code.

Under the Estimated side, I placed the three (3) text boxes on top of each other and removed the Text property from each and then did the same with the actual side using text boxes 4-6.  I then placed a label box under each column respectively called label1 and label2 and finally placed a command button centered underneath the two columns.  Here is the code finally I am using:

Private Sub Command1_Click()
   Dim int FirstNumber As Integer
   Dim int SecondNumber As Integer
   Dim int ThirdNumber As Integer
   Dim int FourthNumber As Integer
   Dim int FifthNumber As Integer
   Dim int SixthNumber As Integer
   intFirstNumber = val(Text1.Text)
   intSecondNumber = val(Text2.Text)
   intThirdNumber = val(Text3.Text)
   intFourthNumber = val(Text4.Text)
   intFifthNumber = val(Text5.Text)
   intSixthNumber = val(Text6.Text)
   Label1.Caption = intFirstNumber + intSecondNumber + intThirdNumber
   Label1.Caption = intFourthNumber + intFifthNumber + intSixthNumber
End Sub

I know how to print object text but that is it.

Please, I neeed help!!!
0
Comment
Question by:lpetrowicz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 20

Expert Comment

by:alainbryden
ID: 17115689
First change
   Label1.Caption = intFourthNumber + intFifthNumber + intSixthNumber
to
   Label2.Caption = intFourthNumber + intFifthNumber + intSixthNumber
unless you want to be overwriting you first label by accident.

There are two ways to compile the data for printing. What I would do is create a new textbox and simply add everything to it.

Dim Output as String
Output =  Text1.text & vbNewLine & Text2.text & vbNewline & Text3.text & _
                vbNewline & "Total: " & Label1.caption & vbNewLine & vbNewline & _
                Text4.text & vbNewLine & Text5.text & vbNewline & Text6.text & _
                vbNewline & "Total: " & Label2.caption

You can organize the data however you want.

Then call up a PrintDialog, if you need help with that let me know, and then to save it you can just output the string to a file and save that.
This will teach you how to use a simple print dialog box.
http://www.developerfusion.co.uk/show/11/4/  or  http://support.microsoft.com/kb/322710/en-us/
And to write a file (very simple) try this:
http://www.tutorialized.com/tutorial/Saving-text-files/11920

Let me know if you encounter and specific error in doing this.

Cheers,

Alain
0
 
LVL 20

Expert Comment

by:alainbryden
ID: 17115694
Oh I almost forgot. The other thing you can do to compile your data is to automatically take a screenshot of the form and then automatically print a picture of the screenshot, but I think that will look a little rough.
0
 

Author Comment

by:lpetrowicz
ID: 17115766
how would you do a screenshot within the program?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:alainbryden
ID: 17115808
http://www.developerfusion.co.uk/show/4630/ or
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4228&lngWId=10
for sample code if you're in a hurry.

I explained it really well in another topic, I'll try to find that.
0
 
LVL 20

Accepted Solution

by:
alainbryden earned 500 total points
ID: 17115827
allright this is what I said:

IF you want to display it, then just loop through each of the form contents with a msgbox, but I'm sure this isn't what you wanted to do or you wouldn't have asked.

IF by print form you mean to use an actual printer, than you need to import the common dialogue box in your components. This is very simple to do, and then you just create a new common dialogue, set the type as PrintDialoge, and then you're off.

If all you want to do is to take a snapshot of a form, like a screenshot type thing, then you need to simulate the pressing of Alt+PrintScreen on the keyboard.  To do this you do the following:

Declare Function keybd_event Lib "user32" Alias "keybd_event" _
     (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, _
     ByVal dwExtraInfo As Long) As Long

so that you can do a keyboard event. THen when you want the screenshot:

keybd_event(VK_Alt, 0, 0, 0) 'send a key
keybd_event(VK_PrintScreen, 0, 0)
keybd_event(VK_Alt, 0, KEYEVENTF_KEYUP, 0) 'release key

Then to store it something like:

frmcontrols.snapImage1.Picture = Clipboard.GetData(vbCFBitmap)



This is where I said it:

http://www.experts-exchange.com/Programming/Q_21889769.html

The guy wanted to do pretty much the same thing as you, print the contents of his form, so take a look at what I wrote there and it will likely solve all your problems. I also show how to properly use the print dialog box
0
 

Author Comment

by:lpetrowicz
ID: 17115936
I will try it all throughout the evening and let you know how it goes.  Thanks.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month6 days, 15 hours left to enroll

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question