Results 1 to 8 of 8

Thread: Array in VB

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2020
    Posts
    20

    Post Array in VB

    I want to have an array in which the user will enter the number inside the array and display all the array number in a textbox or listbox(in a single line)

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,409

    Re: Array in VB

    Please look at your other post....

    and what you are asking here makes little sense.

    Do you want the entries in a TEXTbox or LISTbox? And if on a single line, then LISTBOX is NOT what you'd want

    Have you read MSDN Help on Arrays yet?

    Do you have any BOOKS to help you with VB6 (assuming you are using VB6!)
    Sam I am (as well as Confused at times).

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2020
    Posts
    20

    Re: Array in VB

    Can u tell me more about it?

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,409

    Re: Array in VB

    Answer my questions first...(post #3)
    Sam I am (as well as Confused at times).

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2020
    Posts
    20

    Re: Array in VB

    I want to display it in a TEXTBOX.
    i have not read Any MSDN help on it.
    Basically, i dont have any book on VB6, i am learning it in school and sometimes i always do some searching on it.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Apr 2020
    Posts
    20

    Re: Array in VB

    I want to display it in a TEXTBOX.
    i have not read Any MSDN help on it.
    Basically, i dont have any book on VB6, i am learning it in school and sometimes i always do some searching on it.

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,409

    Re: Array in VB

    1-READ HELP (MSDN) - I'm assuming you have a valid copy
    2-GET A BOOK on VB6
    3-Based upon the example I gave in the other thread, try this:

    Code:
    Option Explicit  'hopefully you have this line!!!!
    Dim nArray() As Double  'declared as form-wide variable
    
    
    Private Sub Command1_Click()  'once everything is in the textbox (a visible so a user will know what he has, do this
        Dim x As Integer
        ReDim nArray(List1.ListCount) As Double
        Text2.Text = ""  'clear anything in the textbox first
        For x = 0 To List1.ListCount - 1
            List1.ListIndex = x
            nArray(x) = List1.Text  'puts what is in the list1 into the array
            If x = 0 Then
                Text2.Text = CStr(nArray(x))
            Else
                Text2.Text = Text2.Text & ", " & CStr(nArray(x))
            End If
        Next x
    End Sub
    
    
    Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then  'once the user selects the Enter key, add the value to the listbox
            If IsNumeric(Text1.Text) Then  'like DM said, check to make sure it is a number
                List1.AddItem Text1.Text
                Text1.Text = ""  'clear the textbox, waiting for the next entry
            Else
                MsgBox "Check your entry...it is not a Number."  'oops, user entered a non-numeric text
            End If
        End If
    End Sub
    Sam I am (as well as Confused at times).

  8. #8
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,051

    Re: Array in VB

    If school, a course, they should give you enough materials/references/books to be able to complete your assignments.
    if you ask here for help, it could mean you are lazy or don't want to buy the book. this is not how you do things.
    and if you want to learn by yourself, theres so much samples on the internet to make you a pro programmer.

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