#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    8
    Rep 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
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    8
    Rep Power
    0

    I need help using tryParse in Visual Basics


    Does anyone know how to use tryParse in Visual Basics?
  4. #3
  5. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,005
    Rep Power
    9398
    Did you know that MSDN often has code samples? Like Int32.TryParse's page has one.

IMN logo majestic logo threadwatch logo seochat tools logo