Solved

help on error message

Posted on 2008-10-02
4
178 Views
Last Modified: 2010-04-21
i got this code that when i get to put a value in room service the whole thing stop working and tell me Conversion from string "" to type 'Double' is not valid."}. my code is suppose to calculate subtotal which is telephoneChg + RoomService + Laundry my code is the follow please help
If TextBox4.Text.Length = 0 AndAlso TextBox5.Text.Length = 0 AndAlso TextBox6.Text.Length Then Exit Sub

If Not IsNumeric(TextBox4.Text) OrElse Not IsNumeric(TextBox5.Text) AndAlso TextBox6.Text.Length Then Exit Sub
 

        dblRoomService = CDbl(TextBox5.Text)

        dblTelephone = CDbl(TextBox4.Text)

        dblLaundry = CDbl(TextBox6.Text)

        Subtotal = dblRoomService + dblTelephone + dblLaundry

        TextBox7.Text = CStr(Subtotal)

        TextBox7.Text = Format(Subtotal, "$#,##0.00")

    End Sub

Open in new window

0
Comment
Question by:elrayiss
  • 3
4 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 400 total points
ID: 22628330
you missed a value at the end of the first line:

If TextBox4.Text.Length = 0 AndAlso TextBox5.Text.Length = 0 AndAlso TextBox6.Text.Length Then Exit Sub
If Not IsNumeric(TextBox4.Text) OrElse Not IsNumeric(TextBox5.Text) AndAlso TextBox6.Text.Length Then Exit Sub
 

should read
If TextBox4.Text.Length = 0 AndAlso TextBox5.Text.Length = 0 AndAlso TextBox6.Text.Length = 0 Then Exit Sub

If Not IsNumeric(TextBox4.Text) OrElse Not IsNumeric(TextBox5.Text) AndAlso TextBox6.Text.Length Then Exit Sub
 

notice the = 0 after TextBox6.Text.Length

 

Open in new window

0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 22628347
also, the second line should read:
If Not IsNumeric(TextBox4.Text) OrElse Not IsNumeric(TextBox5.Text) OrElse Not IsNumeric(TextBox6.Text) Then Exit Sub

 

Open in new window

0
 

Author Closing Comment

by:elrayiss
ID: 31502485
excellent thank you
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 22645844
Glad to be of assistance.

AW
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now