Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default [tut] Extracting data from a list for to a text box

    Welcome to my first tutorial on Visual Basic (or any language for that matter )


    This tutorial is extremely easy and can be used in programs.

    Rating, 1/5 (extremely easy).

    Now to get started!

    Step one: Open Visual Basic, go to File -> New Project (Ctrl + N) and click on Standard EXE when the box pops up



    Step two: Click on the List box and make the box as big as you want, do the same with a text box



    Now it should look a bit like the picture below



    Step three: Now comes the actual coding part, double click on the form and you should see
    Code:
    Private Sub Form_Load()
    
    End Sub
    In the space above End Sub type in the following
    Code:
    With List1
    , this makes it so instead of having to type in List1.AddItem all the time we just have to type in ".AddItem". After you typed With List1 in add the following code
    Code:
      .AddItem "A"
      .AddItem "B"
      .AddItem "C"
      .AddItem "D"
      .AddItem "E"
      .AddItem "F"
      .AddItem "G"
      .AddItem "H"
      .AddItem "I"
      .AddItem "J"
      .AddItem "K"
      .AddItem "L"
      .AddItem "M"
      .AddItem "N"
      .AddItem "O"
      .AddItem "P"
      .AddItem "Q"
      .AddItem "R"
      .AddItem "S"
      .AddItem "T"
      .AddItem "U"
      .AddItem "V"
      .AddItem "W"
      .AddItem "X"
      .AddItem "Y"
      .AddItem "Z"
    please note: you can change the letters to different things like words, numbers, characters and such.

    So now our code should be
    Code:
    Private Sub Form_Load()
    With List1
      .AddItem "A"
      .AddItem "B"
      .AddItem "C"
      .AddItem "D"
      .AddItem "E"
      .AddItem "F"
      .AddItem "G"
      .AddItem "H"
      .AddItem "I"
      .AddItem "J"
      .AddItem "K"
      .AddItem "L"
      .AddItem "M"
      .AddItem "N"
      .AddItem "O"
      .AddItem "P"
      .AddItem "Q"
      .AddItem "R"
      .AddItem "S"
      .AddItem "T"
      .AddItem "U"
      .AddItem "V"
      .AddItem "W"
      .AddItem "X"
      .AddItem "Y"
      .AddItem "Z"
    End With
    End Sub
    Step Four: Double click on the list box and add this code to it
    Code:
    Text1.Text = List1.Text
    this basically tells the text box when we click on a value in the list box we want it to appear in the text box.


    Your finished code should look a bit like this (i added some comments so you get the drift what is happening )

    Code:
    Private Sub Form_Load()
    With List1      ' we add the letters to our list when the form opens
      .AddItem "A"    'you can change the letters to words, characters, numbers etc.
      .AddItem "B"
      .AddItem "C"
      .AddItem "D"
      .AddItem "E"
      .AddItem "F"
      .AddItem "G"
      .AddItem "H"
      .AddItem "I"
      .AddItem "J"
      .AddItem "K"
      .AddItem "L"
      .AddItem "M"
      .AddItem "N"
      .AddItem "O"
      .AddItem "P"
      .AddItem "Q"
      .AddItem "R"
      .AddItem "S"
      .AddItem "T"
      .AddItem "U"
      .AddItem "V"
      .AddItem "W"
      .AddItem "X"
      .AddItem "Y"
      .AddItem "Z"
    End With
    End Sub
    
    Private Sub List1_Click()
    Text1.Text = List1.Text 'When you click a letter from the list box it shows up in the text box
    
    
    End Sub
    That is the end of my tutorial have fun with it.

    C+C is welcome thanks.

    edit: fixed the pictures
    Last edited by Blinger1; 30-01-2007 at 12:26 AM.

  2. #2
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    delete plz

Posting Permissions

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