943,800 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 888
  • VB.NET RSS
Nov 13th, 2007
0

Choice Selection help

Expand Post »
This is the program im trying to write:

http://farm3.static.flickr.com/2324/...0be6bf.jpg?v=0

I have this so far for coding, and its not working. I also get this error "Conversion from string "h" to type 'Boolean' is not valid"



Dim totalstandardhalfday As Double
Dim totalstandardardfullday As Double
Dim totaldeluxehalfday As Double
Dim totaldeluxefullday As Double
totalstandardhalfday = 30 + 32
totalstandardardfullday = 65 + 30
totaldeluxehalfday = 72 + 30
totaldeluxefullday = 144 + 30
If txtitem.Text = "1" & txtduration.Text = "h" Then
lstreceipt.Items.Add("Receipt from Victor's Room Rental")
lstreceipt.Items.Add(" ")
lstreceipt.Items.Add("Standard Rooming" & " $32.00" & " Half-day Rental")
lstreceipt.Items.Add("Deposit" & " $30.00")
lstreceipt.Items.Add("")
lstreceipt.Items.Add("Total:" & " " & FormatCurrency(totalstandardhalfday))
Else : txtitem.Text = "1" & txtduration.Text = "F"
lstreceipt.Items.Add("Receipt from Victor's Room Rental")
lstreceipt.Items.Add(" ")
lstreceipt.Items.Add("Deluxe Rooming" & " $65.00" & " Full-Day Rental")
lstreceipt.Items.Add("Deposit" & " $30.00")
lstreceipt.Items.Add("")
lstreceipt.Items.Add("Total:" & " " & FormatCurrency(totalstandardardfullday))
End If
If txtduration.Text = "2" & txtitem.Text = "H" Then
lstreceipt.Items.Add("Total:" & " " & FormatCurrency(totaldeluxehalfday))
Else : txtduration.Text = "2" & txtitem.Text = "F"
lstreceipt.Items.Add("Total:" & " " & FormatCurrency(totaldeluxefullday))
End If


Thanks In Advance.
Last edited by Magnusz; Nov 13th, 2007 at 1:09 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Magnusz is offline Offline
13 posts
since Oct 2007
Nov 13th, 2007
0

Re: Choice Selection help

In your If statment
VB.NET Syntax (Toggle Plain Text)
  1. If txtitem.Text = "1" & txtduration.Text = "h" Then
You need to use the word AND not &
VB.NET Syntax (Toggle Plain Text)
  1. If txtitem.Text = "1" AND txtduration.Text = "h" Then
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Nov 13th, 2007
0

Re: Choice Selection help

Ahhhh it works perfect Thanks, but now its Doing 2 calculations. how can i fix this?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Magnusz is offline Offline
13 posts
since Oct 2007
Nov 14th, 2007
1

Re: Choice Selection help

It is your Ifs
VB.NET Syntax (Toggle Plain Text)
  1. If * Then
  2. 'Do This
  3. Else
  4. 'Or Do This
  5. End If
  6. 'AND
  7. If *2 Then
  8. 'Do This
  9. Else
  10. 'Or Do This
  11. End If
Fires off the code for one of the Ifs and One Else

Try
VB.NET Syntax (Toggle Plain Text)
  1. If * Then
  2. 'Do This
  3. ElseIf *2 then
  4. 'Or Do This
  5. ElseIf *2 Then
  6. 'Or Do This
  7. Else
  8. 'Or Do This
  9. End If
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Nov 14th, 2007
0

Re: Choice Selection help

Nice. Thanks. Yeah i knew it was something wrong with the ifs, but i didn't know which way to put them. Really Helpful Thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Magnusz is offline Offline
13 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Please How to insert
Next Thread in VB.NET Forum Timeline: Sending strings over IP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC