1 Replies - 5351 Views - Last Post: 20 February 2010 - 09:43 PM Rate Topic: -----

#1 Charlie IronGleet  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 225
  • Joined: 29-January 09

Converting Text to Decimal or Float in VB

Posted 20 February 2010 - 09:31 PM

I am working on a simple asp.net vb.net code behind page.

I need to accept input from an asp textbox control when the user clicks the 'calcButton'

I've set up an event handler for the click:
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub calcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles calcButton.Click
        Dim feetDecimal As Decimal = feet.Text
        

    End Sub
End Class



I looked at the msdn page and it says to use ToDecimal.

Can someone please fix this tiny piece of code for me?

Thanks!
Irongleet

Is This A Good Question/Topic? 0
  • +

Replies To: Converting Text to Decimal or Float in VB

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2233
  • View blog
  • Posts: 9,401
  • Joined: 29-May 08

Re: Converting Text to Decimal or Float in VB

Posted 20 February 2010 - 09:43 PM

You need to try parse the number as a decimal.
Dim feetDecimsl As Decimal
If Decimal.TryParse(feet.Yext,feetDecimal)=False Then
 ' Feet.Text can't be parsed.
Else

End If


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1