Notices
The Basement Non-Honda/Acura discussion. Content should be tasteful and "primetime" safe.

Any one good at Visual Basic??

Thread Tools
 
Old Mar 6, 2003 | 05:49 PM
  #1  
hondav6's Avatar
hondav6
Thread Starter
Senior Member
 
Joined: Jul 2002
Posts: 1,119
Likes: 0
From: La Plata, Maryland
Default Any one good at Visual Basic??

Cause I need some help trying to figure out why my program is not working properly. The program is supposed to give you the total amount due for the number of people registered for an event. You have two option buttons, one check box and a text entry box.

My problem is getting the check box recognized so that a discount can be applied to the total bill. Here is the code:

Private Sub cmdCalc_Click()

Dim Seminar1, Seminar2, Discount As Single
Dim Total_Seminar1, Total_Seminar2, TotDis_Seminar1, TotDis_Seminar2 As Single

Seminar1 = 425
Seminar2 = 550
Discount = 0.9

Total_Seminar1 = Val(txtReg.Text) * Seminar1
Total_Seminar2 = Val(txtReg.Text) * Seminar2
TotDis_Seminar1 = Total_Seminar1 * Discount
TotDis_Seminar2 = Total_Seminar2 * Discount

If Option1.Value = True Then
lblTotal.Caption = FormatCurrency(Total_Seminar1)
End If

If (Option1.Value = True) And (chkDisc.Value = True) Then
lblTotal.Caption = FormatCurrency(TotDis_Seminar1)
End If

If Option2.Value = True Then
lblTotal.Caption = FormatCurrency(Total_Seminar2)
End If

If (Option2.Value = True) And (chkDisc.Value = True) Then
lblTotal.Caption = FormatCurrency(TotDis_Seminar2)
End If

End Sub


Anyone have any clue as to what I have wrong with this? Because when I run the program, My answer comes up in the label box where it is supposed to, but when i click on the box for the discount and press the caluclate button, i get the same answer. Any suggestions?

Greg
Reply
Old Mar 6, 2003 | 06:05 PM
  #2  
swaggs21's Avatar
swaggs21
 
Joined: Dec 2002
Posts: 5,747
Likes: 0
From: Lumberport, WV
Default

Is this .Net or VB6??
Reply
Old Mar 6, 2003 | 06:07 PM
  #3  
hondav6's Avatar
hondav6
Thread Starter
Senior Member
 
Joined: Jul 2002
Posts: 1,119
Likes: 0
From: La Plata, Maryland
Default

This is for VB6 and I am just begining this stuff...oh joy.
Reply
Old Mar 6, 2003 | 06:09 PM
  #4  
swaggs21's Avatar
swaggs21
 
Joined: Dec 2002
Posts: 5,747
Likes: 0
From: Lumberport, WV
Default

where you have chkDisc.Value = True try

chkDisc.Checked

or

UCASE(chkDisc.Value) = "ON"

In any case you can just

MsgBox chkDisc.Value

and see the value
Reply
Old Mar 6, 2003 | 06:12 PM
  #5  
swaggs21's Avatar
swaggs21
 
Joined: Dec 2002
Posts: 5,747
Likes: 0
From: Lumberport, WV
Default

If this does not work, IM me and i will find out, it has been a little while since I have done VB 6, but I am sure I can find it
Reply
Old Mar 8, 2003 | 01:56 PM
  #6  
hondav6's Avatar
hondav6
Thread Starter
Senior Member
 
Joined: Jul 2002
Posts: 1,119
Likes: 0
From: La Plata, Maryland
Default

thanks for the help, but i need some help on this program.

Private Sub cmdCalc_Click()

Dim carbo, fat, protein As Single
Dim total_carbo, total_fat, total_protein, total_calories As Single


carbo = 4
fat = 9
protein = 4

total_carbo = Val(txtCarb.Text) * carbo
total_fat = Val(txtFat.Text) * fat
total_protein = Val(txtProtein.Text) * protein
total_calories = total_carbo + total_fat + total_protein

txtResult = total_calories

***Basically, I have a text box that i need to place results in, I have the total number of calories printing but I can not figure out how to get the text that is supposed to go with the total.

In the text box, it needs to read: The serving contains (total_calories) calories.

Does anyone have any idea?
Reply
Old Mar 8, 2003 | 02:19 PM
  #7  
swaggs21's Avatar
swaggs21
 
Joined: Dec 2002
Posts: 5,747
Likes: 0
From: Lumberport, WV
Default

txtResult.Text = "The serving contains (" & total_calories & ") calories."
Reply
Old Mar 8, 2003 | 02:20 PM
  #8  
hondav6's Avatar
hondav6
Thread Starter
Senior Member
 
Joined: Jul 2002
Posts: 1,119
Likes: 0
From: La Plata, Maryland
Default

thank you sir, my buddy just told me this right before you posted. Your a genious
Reply
Old Mar 8, 2003 | 02:22 PM
  #9  
stephan's Avatar
stephan
:exnbp:
 
Joined: Jul 2001
Posts: 8,728
Likes: 0
From: Henderson, NV
Default

Genius
Reply
Old Mar 8, 2003 | 02:23 PM
  #10  
hondav6's Avatar
hondav6
Thread Starter
Senior Member
 
Joined: Jul 2002
Posts: 1,119
Likes: 0
From: La Plata, Maryland
Default

Originally posted by exnbp
Genius
thank you!, thats what i get for not looking at what i typed. h:
Reply



All times are GMT -8. The time now is 12:05 AM.