Solved

help on error message

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 102
How to set the sa password in a vb6 code for sql connection 9 62
Capture logon name 13 104
Delphi: barcode reading on android platform 1 72
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

749 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