943,561 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 391
  • VB.NET RSS
Sep 28th, 2008
0

help with code.

Expand Post »
i have this project. it calculates the checkout an hotel. first i need it to calculate the first subtotal which is costpernight*numberofnights. and second additionnal charges. its telephone+laundry+roomservice. thats my first step it should be done wihout any button it should appear to the user from inputing the values for each double. this what i got but its not doing the calculation right. i have to input number in all textboxes so it gives me a zero in the total. also i have an error coming up its text is not member of double. please help on this.


Public Class BlueWaterHotelCheckout

Private Total As Double
Private Subtotal As Double






Private Sub NumberOfNights_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub CostPerNight_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub Total_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
Dim dblCostPerNight As Double
Dim dblNumberOfNights As Double


If dblNumberOfNights.Text.Length = 0 OrElse dblCostPerNight.Text.Length = 0 Then Exit Sub ' make sure the user has entered something for both values
If Not IsNumeric(dblNumberOfNights.Text) OrElse Not IsNumeric(dblCostPerNight.Text) Then Exit Sub ' Name sure the user has entered Numbers for both values

dblNumberOfNights = CDbl(dblNumberOfNights.Text)
dblCostPerNight = CDbl(dblCostPerNight.Text)
Total = dblNumberOfNights * dblCostPerNight
TextBox3.Text = Total.ToString
End Sub

Private Sub RoomService_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged

End Sub

Private Sub Telephone_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged

End Sub

Private Sub Laundry_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

End Sub


Private Sub Subtotal_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
Dim dblRoomService As Double
Dim dblTelephone As Double
Dim dblLaundry As Double
Dim Subtotal As Double
TextBox7.Text = Total

If dblRoomService.Text.Length = 0 OrElse dblTelephone.Text.Length = 0 OrElse dblLaundry.Text.Length = 0 Then Exit Sub ' make sure the user has entered something for both values
If Not IsNumeric(dblRoomService.Text) OrElse Not IsNumeric(dblTelephone.Text) OrElse dblLaundry.Text.Length = 0 Then Exit Sub ' Name sure the user has entered Numbers for both values

dblRoomService = CDbl(dblRoomService.Text)
dblTelephone = CDbl(dblTelephone.Text)
Subtotal = dblRoomService + dblTelephone + dblLaundry
End Sub


End Class
Attached Files
File Type: pdf proj2.pdf (277.2 KB, 12 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
elrayiss is offline Offline
1 posts
since Sep 2008
Sep 28th, 2008
0

Re: help with code.

Quote ...
i have to input number in all textboxes so it gives me a zero in the total. also i have an error coming up its text is not member of double. please help on this.
sorry but I don't understand the problem , you mean the total is always zero?
other thing,in your code what the names of the input textboxes , for example is it RoomService or dblRoomService ?

Note:
It is better if use the CODE tag so your post will be easier to read
Last edited by manal; Sep 28th, 2008 at 4:56 pm.
Reputation Points: 37
Solved Threads: 17
Junior Poster
manal is offline Offline
122 posts
since Mar 2006

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: Syntax error in UPDATE statement.
Next Thread in VB.NET Forum Timeline: How to retriev data frm DB in datacombo





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


Follow us on Twitter


© 2011 DaniWeb® LLC