Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Making A Budget Form

Posted on 2006-07-15
6
Medium Priority
?
264 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 21

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 21

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 21

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 21

Accepted Solution

by:
alainbryden earned 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

963 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