Results 1 to 5 of 5

Thread: Help with vb.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Posts
    3

    Help with vb.net

    sorry if this is a really dumb question, but my school just got microsoft visual studio .NET and no one nows how to work it, my main question is why this code doesn't work

    dim x as integer
    dim y as integer

    x = txtX
    y = txtY

    lblsum = x + y

    It blue underlines everything after the equal signs and when I try to run it it says for the first two erros "value of type 'System.Form.TextBox' cannot be converted to Integer"

    the third error is "value Integer cannot be converted to 'System.Windows.Form.label'

    thanks for any answers

  2. #2
    Lively Member
    Join Date
    Sep 2001
    Posts
    83
    In vb.net unlike vb6 you cant just put txtX. You have to use txtX.Text.
    Also youve declared x and y as integers but txtX.Text is a string. You would have to convert it to an integer first.
    Again for the label you have to use lblsum.Text and you have to convert it to a string first.

    I'm new to this too but I think this is right

  3. #3
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    This is what you need to do. When you are trying to get integer values from textboxes, you need to parse it first. So you would do this:

    VB Code:
    1. Dim x as integer
    2. Dim y as integer
    3. Dim total as integer
    4.  
    5. x = integer.Parse(txtX.text)
    6. y = integer.Parse(txtY.text)
    7.  
    8. total = x + y
    9.  
    10. lblsum.Text = total.ToString()

    Hope that helps
    Dont gain the world and lose your soul

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Posts
    3
    thanks for the Help and vb.net is really confusing

  5. #5
    Junior Member El-Phantasmo's Avatar
    Join Date
    Sep 2002
    Posts
    30
    Its only confusing because it does not hold your hand quite as much as VB6.

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