0

This is the program im trying to write:

http://farm3.static.flickr.com/2324/2003724328_63220be6bf.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.

2
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by Magnusz
0

In your If statment

If txtitem.Text = "1" & txtduration.Text = "h" Then

You need to use the word AND not &

If txtitem.Text = "1" AND txtduration.Text = "h" Then
0

Ahhhh it works perfect Thanks, but now its Doing 2 calculations. how can i fix this?

1

It is your Ifs

If * Then
  'Do This
Else
  'Or Do This
End If
                              'AND
If *2 Then
  'Do This
Else
  'Or Do This
End If

Fires off the code for one of the Ifs and One Else

Try

If * Then
  'Do This
ElseIf *2 then
  'Or Do This
ElseIf *2 Then
  'Or Do This
Else
  'Or Do This
End If
Votes + Comments
Helpful, understood what i wanted to get out of my program
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.