Solved

Making A Budget Form

Posted on 2006-07-15
6
228 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now