Archived

This topic is now archived and is closed to further replies.

Chalma

VB functions you define yourself

Recommended Posts

Chalma    122
Private Sub Form_Load() cboCharRace.AddItem "Human", 0 cboCharRace.AddItem "Half-Elf", 1 cboCharRace.AddItem "Elf", 2 cboCharRace.AddItem "Dwarf", 3 cboCharType.AddItem "Hunter", 0 cboCharType.AddItem "Warrior", 1 cboCharType.AddItem "Wizard", 2 cboCharType.AddItem "Priest", 3 End Sub Ok I''m a real nit picker for neat code I don''t like this at all. Is there any way I can make a function that loads in the on on load so that it does this I can do this in C but not in VB or maybe I''m doing it wrong. an example of what I would like to do is......
quote:
Private Sub Form_Load() LoadCharRace() LoadCharType() End Sub /////////////////////////////////////////////////// Private Function LoadCharRace() cboCharRace.AddItem "Human", 0 cboCharRace.AddItem "Half-Elf", 1 cboCharRace.AddItem "Elf", 2 cboCharRace.AddItem "Dwarf", 3 End Function ///////////////////////////////////////////////// Private Function LoadCharType() cboCharType.AddItem "Hunter", 0 cboCharType.AddItem "Warrior", 1 cboCharType.AddItem "Wizard", 2 cboCharType.AddItem "Priest", 3 End Function
VB just will not let me do this. It wants me to make a return type but I don''t want a friggin'' return type this is easibly doable in C++ and I really want to get better with VB so any help is appreciated. I know the code is not right the second way that is [u]THEORETICAL [/u] code, its how I would picture it looking. THanks -Chalma/Pspiro

Share this post


Link to post
Share on other sites
ragonastick    134
If you are just hardcoding those items in, then you might as well do it at design time.

Select the list box, go to its properties and find the List property. Click the down arrow, then type the first item, then press Ctrl+Enter, second item ctrl+enter etc until you type the last, when you just press enter.

Trying is the first step towards failure.

Share this post


Link to post
Share on other sites