Author Topic: Populating Form Controls at runtime  (Read 5169 times)

0 Members and 2 Guests are viewing this topic.

Guest

  • Guest
Re: Populating Form Controls at runtime
« Reply #15 on: April 27, 2007, 01:34:10 PM »
An array of controls in VBA is not possible like it is in straight VB.  You can kinda "fudge" it, but I've always found that it's easier to work with controls that have unique names and not CombBox(0), ComboBox(1), etc...  Call it "personal preference", but I think it's easier that way.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Populating Form Controls at runtime
« Reply #16 on: April 27, 2007, 03:55:36 PM »
What I was trying to do was determine which option was selected.  I was thinking of the array (I learned to do that in C#) where I could cycle through the array and find the selected control.  I ended up using select case to parse the controls.  Is there a better way?  Bryco, I saw your post, but have been in meetings all day, so I haven't had a chance to look into that yet.
Code: [Select]
      Dim booTrue As Boolean
      booTrue = True
      Select Case booTrue
            Case frmSetup.optBS3.Value
                  ThisDrawing.SetVariable "USERI4", 3
            Case frmSetup.optBS4.Value
                  ThisDrawing.SetVariable "USERI4", 4
            Case frmSetup.optBS5.Value
                  ThisDrawing.SetVariable "USERI4", 5
            Case frmSetup.optBS6.Value
                  ThisDrawing.SetVariable "USERI4", 6
      End Select
      Select Case booTrue
            Case frmSetup.optVC138kv.Value
                  ThisDrawing.SetVariable "USERS2", "138"
            Case frmSetup.optVC69kv.Value
                  ThisDrawing.SetVariable "USERS2", "69"
            Case frmSetup.optVC46kv.Value
                  ThisDrawing.SetVariable "USERS2", "46"
            Case frmSetup.optVC230kv.Value
                  ThisDrawing.SetVariable "USERS2", "230"
            Case frmSetup.optVC345kv.Value
                  ThisDrawing.SetVariable "USERS2", "345"
      End Select
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

jjs

  • Guest
Re: Populating Form Controls at runtime
« Reply #17 on: April 27, 2007, 04:46:46 PM »
Randall or the llama had some code to fool vba into thinking there were control arrays. I tried it and did not like it so much. With the few number of controls you have, you are better off doing it how you currently are.

Are you calling those user variables from a lisp routine or vba routine?

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Populating Form Controls at runtime
« Reply #18 on: April 27, 2007, 06:04:51 PM »
VBA
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

jjs

  • Guest
Re: Populating Form Controls at runtime
« Reply #19 on: April 29, 2007, 03:45:35 PM »
is the vba routine inside this project, or a different one?

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Populating Form Controls at runtime
« Reply #20 on: April 30, 2007, 10:03:09 AM »
this one
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)