• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

vba - array e listbox

  • Thread starter Thread starter reb_bl
  • Start date Start date

reb_bl

Guest
Hi.
I would need to create a sort of table inside the default.ivb with a list of machines with relative description, then recall from combolist and use the number of the machine. this serves because we designers know the machines for description while others by number. I must therefore create a table in which in column 1 there is written "machine 1" and in column 2 "pipe machine" in such a way that visually in the listbox I read "pipe machine" but go to write "machine 1".
I need an external table because I have more functions in which to recall the value "machine 1".
I do not want to use external applications unless it is strictly forced.

Can anyone help me?
 
I'm not in a hurry, in the sense that I've been blinding.
I am gross in the same situation as the first link, the table, in some way as help of vba I made it, and I have to try again in 4 (for now, in the future perhaps more) occasions.
I would like to go in the future to change only one array, for data management/reading problems.
 
if I understood the problem my approach would be a common external file from which they draw the various programs/macro that you will... What do you mean, "reprove it"? then once loaded into memory in an array the problem becomes as you do the program and that is another matter.
the example posted used excel, the same thing works with a .txt file...
 
if I understood the problem my approach would be a common external file from which they draw the various programs/macro that you will... What do you mean, "reprove it"? then once loaded into memory in an array the problem becomes as you do the program and that is another matter.
the example posted used excel, the same thing works with a .txt file...
I don't want to resort to an external file, more than anything else to have a single file to be dismantled in the future, maybe to make it so much weighting the whole?
in good substance I have 4 comboboxes with drop-down menus that can take 4 different values: from incapable I have created 4 comboboxes with inside each funnel combo a list.
I wanted to improve everything.
 
as said everything depends on how you did the program... you can also have a unique array compiled within the program once and then always use that to fill your listboxes each time, it will be up to you if you use the array as a global variable or invent other more elegant artifacts. . .
 
as said everything depends on how you did the program... you can also have a unique array compiled within the program once and then always use that to fill your listboxes each time, it will be up to you if you use the array as a global variable or invent other more elegant artifacts. . .
I really want to do this!
... but I can't. . :
 
I hope you're more able to pay beers :p
code for vba
Rich (BB code):
'You put this in the various forms that contain the combobox, adapting the combobox and form names
private sub userform_initialize()
call compilecombobox(myform.combobox1)
end

'This is a general sub that always compiles in the same way the combobox parameter that is passed
' to put in a form
public sub compilecombobox(mycombo as combobox)
mycombo.additem ("tizio")
mycombo.additem ("caio")
mycombo.additem ("sempronium")
end
 
Last edited:
Rich (BB code):
'You put this in the various forms that contain the combobox, adapting the combobox and form names
private sub userform_initialize()
call compilecombobox(myform.combobox1)
end
Rich (BB code):
I was probably missing, I'm putting on an ad hoc module the array?
 
the sub compilecombobox you can put it in any form, if I make a little elaborate macros I usually do a special form but it is not necessary; will be available in all your forms/programs (being public).
instead the sub userform_initialize() is a sub "preset" that runs every time the form that contains it starts: then it must be copied in each of your forms, and will only work for that specific form (being private).

Anyway:
a) I am not a programmer and so I can shoot st..upidaggini.
(b) beer is for commitment and not for the quality of the support if we fall within the a) ;)
 
Unfortunately now I'm short of time, as soon as I'm a little free I try and then I tell you how it went!
 
I exhume, as I think I have a few hours available here and there.
refreshing the memory:

I am currently in this situation:
Code:
combog1. additem "125", 1
combog1.list(1, 1) = "macchina 1"
combog1.additem "146", 2
combog1.list(2, 1) = "macchina 2"
combog1.additem "153", 3
combog1.list(3, 1) = "macchina 3"
combog1.additem "160", 4
combog1.list(4, 1) = "macchina 4"
combog1.additem "161", 5
combog1.list(5, 1) = "macchina 5"
combog1.additem "176", 6
combog1.list(6, 1) = "macchina 6"
combog1.additem "180", 7
combog1.list(7, 1) = "macchina 7"
combog1. additem "186", 8
combog1.list(8, 1) = "macchina 8"
so: I read "machine ..." but I go to popular the relative numerical value in iprops; as you can see I have various combobox "combog1" and so on.

to make an array (public) where to read "machine ..." and write its value as I do?

I think I get it, I think...
 
the code posted initially does what you ask:
- create your combobox combog1, combog2, etc.;
- call the sub compilecombobox(mycombo) through combog1, combog2 etc as a parameter;
- the sub compilecombobox(...) will contain the code needed to compile the comboboxes
 
the code posted initially does what you ask:
- create your combobox combog1, combog2, etc.;
- call the sub compilecombobox(mycombo) through combog1, combog2 etc as a parameter;
- the sub compilecombobox(...) will contain the code needed to compile the comboboxes
I'm sorry, but I'm lost, I'm a little jogging if you can give me a "regulated"
 

Attachments

recalls compilation by userform_activate() and not by combobox_click():
Code:
private sub userform_activate()
    call compilacombobox(userform.combog1)
    call compilacombobox(userform.combog2)
end sub
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top