locked
the link, the code, the headache RRS feed

  • Question

  • http://msdn.microsoft.com/en-us/library/ms172582(VS.90).aspx
    Dim players() As String = {"Dan", "Fred", "Bart", "Carlos", _
      "Ty", "Juan", "Jay", "Sam", "Pedro"}
            Dim i As Integer = CInt(Textbox1.Text)
            MsgBox(players(i) & " is on first base.")

    i get an error textbox1 not declared. i see the message box in the code that's supposed to come up, i'm thinking "what's going on?" then i figure "hey! try putting a textbox on the form & see what happens..." well, then i get the error string to integer conversion isn't valid??!?  i know THAT can be done!!  my question is how the heck can a beginner learn anything on samples like this??!?
    Thursday, May 31, 2012 12:05 AM

Answers

  • sorry my bad!!  i seemd to have gotten into a hurry and skipped some steps in the example...

    If that resolves your issue, please close the thread by marking any appropriate replies as answer.

    Thanks!


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Namyegob Thursday, May 31, 2012 3:06 AM
    Thursday, May 31, 2012 1:23 AM

All replies

  • You need to make the TextBox contain a number from 0 to 8, since there are 9 Players.  This will cause the CInt call to function properly.


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Thursday, May 31, 2012 12:14 AM
  • so, i played around with it a little bit, changed up the code some...
    Dim players() As String = {"Dan", "Fred", "Bart", "Carlos", _
      "Ty", "Juan", "Jay", "Sam", "Pedro"}
            'Dim i As Integer = CInt(TextBox1.Text)
            Dim count As Integer
            For count = 0 To 8
                TextBox1.Text = CInt(count)
                Dim i As Integer = CInt(TextBox1.Text)
                MsgBox(players(i) & " is on first base.")
            Next count
            'Dim i As Integer = CInt(TextBox1.Text)
            'MsgBox(players(i) & " is on first base.")

    but that doesn't answer the original question how was i supposed to learn anything from the example when the example didn't work, you provided some help is stating that i needed to make the textbox contain a number whereas the example should have shown that...  all i learned is that the whole freakin team is standing on first base!!?!  lol
    Thursday, May 31, 2012 1:07 AM
  • If you follow the step-by-step instructions in that link, it walks you through how you'd know.  In particular, steps 7, 8, and 9. 

    In your case, step 9 was missing originally: "Type a number between 0 and 8 in the text box and click the button. The name corresponding to that element is displayed in a message box."  Had you typed a number from 0 to 8 as the text, it would work as-is.

    You'll find that most of the tutorials/code samples require specific instructions to be followed exactly in order to work.  Once you have it working, you can step through to see how and why it works.


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".


    Thursday, May 31, 2012 1:10 AM
  • sorry my bad!!  i seemd to have gotten into a hurry and skipped some steps in the example...
    Thursday, May 31, 2012 1:11 AM
  • sorry my bad!!  i seemd to have gotten into a hurry and skipped some steps in the example...

    If that resolves your issue, please close the thread by marking any appropriate replies as answer.

    Thanks!


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by Namyegob Thursday, May 31, 2012 3:06 AM
    Thursday, May 31, 2012 1:23 AM