Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Confused about control arrays (VB5)

    Trying to understand how control arrays work in VB5 -- I think that I am getting confused by trying to use Access97 syntax.

    I have a control array called Sync1, and it has three Option Buttons with Index values of 0, 1, and 2. What I want to do is to call a function like this:

    x = SomeFunction(sync1)

    and I want it to pass a 0, 1, or 2 depending on which Option Button is selected.

    How do I refer to the current value of the array? I am used to dropping option buttons into a frame in Access, and referring to the value of the frame. Does the same principle apply?? Or am overlooking something very obvious?
    <img src=/S/frown.gif border=0 alt=frown width=15 height=15>

    Thanks for your help
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Confused about control arrays (VB5)

    Jack, it would be good if you changed the name of your control array to optSync1. Just nitpicky of me, but that way other VB programmers will know that they are option buttons (I usually also add an s at the end so that I know that it is more than one button). You can only refer to the value of each one of the buttons in this array: optSync1(0).Value, optSync1(1).Value, and optSync1(2).Value. Each of these values is either True or False. So, to turn this into a 0,1,2:<pre>Dim iSync1 as Integer
    If optSync1(0) then
    iSync1 = 0
    ElseIf optSync1(1) then
    iSync1 = 1
    Else
    iSync1 = 2
    EndIf</pre>

    You probably noticed that I didn't use the .Value: Value is the default property, so I can leave it out. I also assumed that you had exactly 3 option buttons and one of them had been set true during design. Hope this helps! --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Confused about control arrays (VB5)

    Thanks for the info. You confirmed that option buttons work differently in VB than in Access, so I know that I wasn't overlooking something.

    You are right about the control names, and I usually follow your method. Was getting very frustrated with the differences between VB and Access, and had to create and delete the controls several times. Got lazy.... But I am feeling much better now <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Confused about control arrays (VB5)

    Jack, I felt the same way <img src=/S/drop.gif border=0 alt=drop width=23 height=23> when I did some Access programming, but ended up liking Access features better. Sorry that you have to downgrade to VB. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Confused about control arrays (VB5)

    I agree, Sam. I started out with Access and had a terrible time with VB because you have to work SO hard to do things like populate a combobox or worse, to handle the items selected in a combo or listbox. I balk at any serious work with databases in VB because the functionality just isn't there for forms, controls and reports. Maybe someday. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

  6. #6
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Confused about control arrays (VB5)

    Gee -- it's kinda reassuring to know that I'm not alone. I've read a lot about VB and its power, but most of my experience has been with Access. I am always spinning my wheels with VB -- thought that it was just me. Glad (???) to see that someone with Charlotte's depth of knowledge is similarly befuddled.
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

Posting Permissions

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