
October 24th, 2012, 07:46 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 8
Time spent in forums: 2 h 17 m 34 sec
Reputation Power: 0
|
|
|
I Need Help Using tryParse in Visual Basics
Hi, everyone. I am new to this site, just found it. My ? is this. I wrote a code for an assignment I had in my book, but didn't use tryParse. My book uses this method and I am totally lost with it.
Here is the code that I have and it works. I need to convert it using tryParse, any ideas where to start?
Option Strict On
Option Explicit On
Public Class MainForm1
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles exitButton3.Click Me.Close()
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles clearButton.Click
lengthBox.Text = String.Empty
widthBox.Text = String.Empty
squareftBox.Text = String.Empty
areaBox.Text = String.Empty
totalBox.Text = String.Empty
End Sub
Private Sub lengthLabel_Click(sender As System.Object, e As System.EventArgs) Handles lengthLabel.Click
Dim lengthLabel As Double = CDb(Me.lengthBox.Text)
End Sub
Private Sub widthLabel_Click(sender As System.Object, e As System.EventArgs) Handles widthLabel.Click
Dim widthLabel As Double = CDbl(Me.widthBox.Text)
End Sub
Private Sub calculateButton1_Click(sender As System.Object, e As System.EventArgs) Handles calculateButton1.Click
Dim lengthLabel As Double = CDbl(Me.lengthBox.Text)
Dim widthLabel As Double = CDbl(Me.widthBox.Text)
Me.areaBox.Text = Format(lengthLabel * widthLabel, "#,##0.00")
Dim totalprice As Double = CDbl(Me.squareftBox.Text)
Dim areaLabel As Double = CDbl(areaBox.Text)
totalBox.Text = Format(lengthLabel * widthLabel * totalprice, "C2")
End Sub
End Class
Last edited by hemihead_dave : October 24th, 2012 at 08:06 PM.
Reason: title correction
|