Solved

Making A Budget Form

Posted on 2006-07-15
6
233 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add a task in Outlook from access 11 39
Search combo error "Data Type Mismatch in Criteria Expression" 2 63
Child Form in front 4 47
Send outlook email from VBS Script 2 30
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

821 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