473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Invalidecastexception was unhandled

3
I know I am new and this prolly a dumb question... I have no BS been working on this issue for the last 5 HOURS!!! Some one gimme a little insight PLEASE!

This is the error I get:
Conversion from string "" to type 'Double' is not valid.
on this line:
TextBox3.Text = TextBox1.Text * TextBox2.Text


And this is my code...

What am I doing wrong?

Public Class Form1

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End 'closes the program
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'clears everything
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
Me.CheckBox1 = Me.CheckBox1

End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Text = TextBox1.Text * TextBox2.Text 'subtotal
If TextBox4.Text > 0 Then 'if the check box is checked adds electricity
TextBox5.Text = TextBox3.Text + TextBox4.Text
Else : TextBox5.Text = TextBox3.Text 'if not checked it skips electricity
End If
If DateDiff("d", Me.DateTimePicker1, Me.DateTimePicker2) < 1 Then 'error message for date problems
MsgBox("Start Date can not be before End Date")

End If

End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
TextBox2.Text = 25.0 'cheap
End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
TextBox2.Text = 35.0 'middle price
End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
TextBox2.Text = 50.0 'most expensive
End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
TextBox4.Text = TextBox1.Text * 10 'adds electricity charges
End Sub

Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
TextBox5.Text = Format(TextBox5.Text, "currency")
If TextBox4.Text > 0 Then 'if there is an electric charge then add the two together
TextBox5.Text = TextBox3.Text = TextBox4.Text
Else 'if not then just repeat the same number
TextBox5.Text = TextBox3.Text
End If
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Text = DateDiff("d", Me.DateTimePicker1, Me.DateTimePicker2)
End Sub


Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
TextBox2.Text = Format(TextBox2.Text, "currency")
End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
TextBox3.Text = Format(TextBox3.Text, "currency")
End Sub

Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
TextBox4.Text = Format(TextBox4.Text, "currency")
End Sub
End Class
Oct 14 '07 #1
2 1206
Shashi Sadasivan
1,435 Expert 1GB
what do you want to do ,,,,
the pseudocode of the error line is string1 multiplied by string2 = string3

isint it supposed to be number1 multiplied by number2 = number3 ?

guess you need a book!

cheers
Oct 14 '07 #2
Plater
7,872 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. TextBox3.Text = TextBox1.Text * TextBox2.Text 
  2.  
* is a math operator and you are trying to apply it to two string objects.
Convert them to a number of some sort before performing math operations.

Expand|Select|Wrap|Line Numbers
  1. double a=double.Parse(TextBox1.Text);
  2. double b=double.Parse(TextBox2.Text);
  3. TextBox3.Text= (a*b).ToString();
  4.  
You can condense that as you desire.
Oct 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
5
by: Dave Stewart | last post by:
I recently wrote my first Vb.net application, or at least my first complex app since moving up from vb6. When run from the VS.NET IDE, the program shows no errors and runs fine. When the output exe...
5
by: Lucvdv | last post by:
Can someone explain why this code pops up a messagebox saying the ThreadAbortException wasn't handled? The first exception is reported only in the debug pane, as expected. The second (caused by...
5
by: Samuel R. Neff | last post by:
When you have an unhandled exception in vb.net how do you view the exception information in the debugger? In C# the debugger creates a local variable that points to the exception and you can...
0
by: Colmeister | last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions (http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have attempted to incorporate the features he talks...
3
by: NickP | last post by:
Hi there, Im experiencing an unhandled exception that seems to be impossible for me to catch. I am launching an assembly of mine from within another assembly using the Process object. Once the...
2
by: Bob | last post by:
I MUST be able to trap unhandled exceptions, bring the thread to a routine that then closes the thread on which the execption occurred without closing or affecting the other threads. Think of an...
0
by: Bob | last post by:
If I induce and unhandled exception in my vb.net code for instance using '-- just a simple "object not initialized" exception (should read "as new") Dim x As Specialized.NameValueCollection ...
1
by: Bob | last post by:
In Vs 2005 you have new applicationsEvents.vb I was testing it in a simple app and found that it was easier to implement unhandled exception management tah it was in Vs2003 (vb.net) You can, if you...
5
by: =?Utf-8?B?c3VydHVyeg==?= | last post by:
Hi, I feel like a noob for asking this. When I publish a VB windows application, I want to disable the ability of the the user to continue when there is an unhandled exception. For example,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.