CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2001
    Posts
    6

    outputing integers

    Private Sub cmdConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConvert.Click

    Dim intInput As Integer

    intInput = txtInput.Text()

    txtOutput.Text = intInput



    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    Me.Close()
    End Sub
    End Class

    The problem is that the only way this works is if i declare intInput as a string how can i get this to work as an integer?

  2. #2
    Join Date
    May 2002
    Location
    Växjö, Sweden
    Posts
    15
    Whatever you get from at textbox is usually a "text", that is a string.

    So you can check and validate whatever someone puts in that box to be a numerical value of your choice, preferably with the help of the "Errorprovider"-component.

    Then in code you use Cint(txtbox.text), or Csng(txtbox.text) or whatever you feel is necessary, if you need to perform any numerical functions etc...

  3. #3
    Join Date
    Oct 2002
    Location
    Northwest Illinois, USA
    Posts
    6
    Another option would be to use the following:

    intInput = val(txtInput.text)

    ZebbCarter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured