Results 1 to 21 of 21

Thread: See / edit an array

  1. #1

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371

    Unhappy See / edit an array

    Hi guys...

    I'm a beginner in VB.. my version is 6

    I'm trying to display an array, but I don't know how

    I would also like to edit the values of the array while in exe mode...

    I don't How to do it... Can you guys help me???

  2. #2
    Lively Member freightliner's Avatar
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    123
    VB Code:
    1. dim x(0 to 2) as integer
    2. x(0)=1
    3. x(1)=2
    4. x(2)=45
    5. for i = LBOUND(x) to ubound(x)
    6.    msgbox x(i)
    7. next
    very handy: [vbcode][/vbcode]
    VB.NET - VB6 - VBA - ASP - RPG(AS/400) - C++ - java - SQL

    look in the help, many probs can be solved that way.
    I know, i'm to lazy too.

    PLEASE PUT RESOLVED IF RESOLVED!!

  3. #3

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    well... I'm a beginner but not that mutch of a beginner...


    now really.. I'm didn't explained very well what I wanted...

    I want to be able to see as if in a label the values I had inserted or manipulated in the array, and I would also liked to edit them..

  4. #4
    Lively Member freightliner's Avatar
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    123
    and now in english

    sorry, but your sentence is not well constructed, i am not english myself, maybe it's that :s
    very handy: [vbcode][/vbcode]
    VB.NET - VB6 - VBA - ASP - RPG(AS/400) - C++ - java - SQL

    look in the help, many probs can be solved that way.
    I know, i'm to lazy too.

    PLEASE PUT RESOLVED IF RESOLVED!!

  5. #5

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    I'll try my best...

    It's like this:

    I have an array (ex:test(1 to 100) as integer) and I would like to see all of the values of the array in a Label (or whatever) while executing the program ...

    I would also like to change the values in the label (or Whatever) and the program automaticly changes the value in the array...

    I'm trying to do my best here ... If you don't understand . please say..

  6. #6
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492
    Hello

    You've got the array¿

    If you want to display the info inside the array:

    label1.Caption = CStr(test(0))
    label2.Caption = CStr(test(1))


    Is that what you are after¿¿

    Hannes
    VB.NET MVP 2008 - Present

  7. #7

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    That works if you only want to display, and even so it only works for a small array...

    the problem is I can't edit the values.. and subsequently change the values in the array (inside the program)...

    other problem.. that could partialy be solved if I could insert in to a list ... is to show all the array in one object, with no limits (I could insert values, thus inserting in the array), or wiht a very high limit...

    maybe this is a bit tough... but is necessary for my project to work!!!..

  8. #8
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492
    try this then:

    VB Code:
    1. 'this should load tha array into a combo box
    2.  
    3. Dim i as integer
    4. For i = 0 to UBound(test)
    5. combo1.AddItem CStr(test(i))
    6. Next i
    VB.NET MVP 2008 - Present

  9. #9

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    Actually I can't try it right now...

    but ... by the way what does the cstr() do??..

    ..and Will I be able to insert values in the combo box thus inserting in the array??..

  10. #10
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492
    The CStr converts the Integers to strings.
    VB.NET MVP 2008 - Present

  11. #11
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762
    try putting the array values into a text box with multiline property true like this

    assume your array is s()

    Code:
     
    textbox.text = ""
    for i = LBound(s) to UBound(s)
        textbox.text = s(i) & vbcrlf
    next i

    the text box will allow you to edit the values, then in a button click event, put the values back into the array using the split function
    Code:
     
    s=split(textbox.text,vbcrlf)
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  12. #12

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    But what I'm trying to use is a 2 dimension array, does this also work with that ... is it possible to have more then 1 colum in the text box??

  13. #13
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383
    What about using a flexgrid control instead?
    There is code in the codebank on how to write to it.

  14. #14

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    can you give me the link??...

    I can't find it anywere!!!

  15. #15
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    Another possibility would be to use two list boxes. The first list box holds the first dimension of the array, and when you double-click on one item, the second list box gets filled with the second dimension that corresponds to that first dimension. I think the tree view could do that, too, but I don't have much experience with that.

    The flexgrid control would be most obvious, but being able to edit in it cleanly can take some trickery that might be more than you want.

  16. #16

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    the two (or more) list boxes idea seemes great... how can I do it(in code.. please!!)?

    I'm trying to build a 6 column display (list box or whatever)..


    and what about that flexgrid control everybody talks about?? Where can I find it??..

    However dificult.. I just want to learn!!!...

  17. #17
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762
    Originally posted by Shaggy Hiker
    Another possibility would be to use two list boxes. The first list box holds the first dimension of the array, and when you double-click on one item, the second list box gets filled with the second dimension...
    nice!
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  18. #18

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    come on guys ...

    can you please give me the code (functions) for the flexgrid control or the 6 colums text box ...

    PS: F.C.Porto Rules!!... Were EUROPEAN CHAMPIONS!!!!...

  19. #19

  20. #20

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    I used the first code, and it is great... You guys RULE!!!... (the second I couldn't make it work... neither could I understand it)

    thanks a lot...

    however there is still a little setback: I can't insert new cells while in execution mode, and neither can I save the changes...

    I'm thinking to save the new value in the flexgrid_click sub function, when the user presses <enter> however I haven't had much success...

    can you guys give a little push

    (If possible in code )

  21. #21

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371
    ....
    is anybody out there???...
    ....
    come on.. I know you know how to do it...

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