Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,184 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,059 people online right now. Registration is fast and FREE... Join Now!




Blank Error

 
Reply to this topicStart new topic

Blank Error

Mather
20 Sep, 2007 - 04:45 PM
Post #1

New D.I.C Head
*

Joined: 20 Sep, 2007
Posts: 3


My Contributions
CODE

Option Explicit
    Dim hours As Single
    Dim parts As Single
    Dim labor As Single
    Dim tax As Single
    Dim total As Single

Private Sub bill_Click()
    tax = 1.18
    labor = b2 * 35
    hours = Val(b2.Text * 35)
    parts = Val(b3.Text + tax)
    total = hours + parts
    result.Print "Customers :       "; b1
    result.Print "Labor Cost :      "; FormatCurrency(labor)
    result.Print "Part Cost :         "; FormatCurrency(parts)
    result.Print ""
    result.Print "Total :               "; FormatCurrency(total)
End Sub

Private Sub clear_Click()
    b1.Text = ""
    b2.Text = ""
    b3.Text = ""
    result.Cls
    b1.SetFocus
    b2.SetFocus
    b3.SetFocus
End Sub

Private Sub exit_Click()
    End
End Sub


2 problems and 1 comes with a error.

1st: I was suppose to put in a 5% sale tax to the Parts, Can u tell me if i did it right?

2nd: When i enter a name/hours of labor/cost of parts, the result is successful, BUT when nothing is enter, when all 3 textboxes are empty and then i press "Bill" and i would get a error "run-time error '13': Type mismatch"
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Blank Error
20 Sep, 2007 - 05:10 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Question 1:

If this line is your sales tax tax = 1.18 then no you didnt do it right. A 5% sales tax would look like tax = 0.05.

Question 2:

You're getting this error because its trying to perform math on empty strings, that aint going to work. You need to check and make sure all 3 textboxes have a value, and that they're numeric before calculating anything.

Example:

CODE

If Not b3.Text = "" And IsNumeric(b3.Text) Then
      'Do your processing here
Else
       'Display an error here
End if


That example accounts for a single textbox, you have 2 more to go.

Hope this helps smile.gif
User is offlineProfile CardPM
+Quote Post

Mather
RE: Blank Error
24 Sep, 2007 - 04:31 PM
Post #3

New D.I.C Head
*

Joined: 20 Sep, 2007
Posts: 3


My Contributions
QUOTE(PsychoCoder @ 20 Sep, 2007 - 06:10 PM) *

Question 1:

If this line is your sales tax tax = 1.18 then no you didnt do it right. A 5% sales tax would look like tax = 0.05.

Question 2:

You're getting this error because its trying to perform math on empty strings, that aint going to work. You need to check and make sure all 3 textboxes have a value, and that they're numeric before calculating anything.

Example:

CODE

If Not b3.Text = "" And IsNumeric(b3.Text) Then
      'Do your processing here
Else
       'Display an error here
End if


That example accounts for a single textbox, you have 2 more to go.

Hope this helps smile.gif



hey man
thanks for the help

when i put "tax = 0.05" and the output came out weird but when i put "b3 * 0.05" and it came out what i wanted and what was in the book. so yea thanks for the help

2nd: about the error, my prof. told me we weren't up to that part, so LOL


User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Blank Error
24 Sep, 2007 - 06:03 PM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
No problem, thats what we're here for smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 01:12AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month