Solved

help on error message

Posted on 2008-10-02
4
181 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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