Jan 6th, 2007, 09:56 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Creating Control Arrays During Runtime
I am creating a program where there is not necessarily a specific number of items in the menu...I was wondering if there is a specific way of creating a control during runtime... I'll have a minimum of one label... but I just want to make copies of it... but still be able to access them individually...
I remember seeing something like that... but I couldn't find it in the search... or maybe I am just not typing the correct keyword
If anyone could help or give me a link to that thread... I'd really appreciate it...
Khanjan
Hey... If you found this post helpful please rate it.
Jan 6th, 2007, 10:11 PM
#2
Re: Creating Control Arrays During Runtime
Create the array in design time, and say the user calls something that needs a new label:
VB Code:
Load (lblMyLabel(UBound(lblMyLabel + 1)), Label)
Please note that has not been tested, but it should be close.
Jan 6th, 2007, 10:12 PM
#3
Re: Creating Control Arrays During Runtime
Put one on your form and set it's Index to 0. You can hide it if you want and make it visible if you need just one. After that you Load new ones, making sure you make them visible and moving them where you want them.
Jan 6th, 2007, 10:30 PM
#4
Thread Starter
Hyperactive Member
Re: Creating Control Arrays During Runtime
Well... timeshifter you are close enough... you gave me that hint of the keyword "Load"
However the prompt I get for the format is ....
Code:
Load(Object As Object)
I enter:
VB Code:
Private Sub Command1_Click()
Static intCount As Integer
intCount = intCount + 1
Load (Label1(intUCount) As Label)
End Sub
I get an error with "As"
The error is:
Code:
Expected: list seperator or )
I get an error with your code too... at "+"
For the "+" the error is:
Code:
Expected: List Seperator
Hey... If you found this post helpful please rate it.
Jan 6th, 2007, 10:36 PM
#5
Fanatic Member
Re: Creating Control Arrays During Runtime
Have fun making Opbects
VB Code:
'
' SESSI4ML 10/10/2006
' Create Objects...or, create new Objects as the user needs them
'
'Option Explicit
'
' VBforums.com ....
'
Private Sub Form_Load()
Command3.Caption = "Make Objects"
Command1.Caption = "Single Step"
Text1.Text = 10
End Sub
Private Sub Command3_Click()
For a = 1 To Val(Text1.Text)
Call Command1_Click
Next
End Sub
Private Sub Command1_Click()
' what is the object count
' text1= number of objects to create
'
intobj = Command2.Count ' Points to the next Object
Load Command2(intobj) ' command2 will always default to index 0 for the load
' ready to create new object
' Create new object
' Create a new Row
'
If intobj / 5 = Int(intobj / 5) Then
' Create a new Top for object
Command2(intobj).Top = Command2(intobj - 1).Top + Command2(intobj).Height + 10
Command2(intobj).Left = 120 ' Start on Left column
Command2(intobj).Visible = True
Command2(intobj).Caption = Command2(intobj).Index
Exit Sub
End If
'
Command2(intobj).Top = Command2(intobj - 1).Top
Command2(intobj).Left = Command2(intobj - 1).Left + Command2(intobj - 1).Width + 5
Command2(intobj).Caption = Command2(intobj).Index
Command2(intobj).Visible = True
End Sub
'
Alpha Micro: Alpha Basic, AS400 V5r2, EDI (Trusted Link/ Inovis.com),Access AS/400 via VB6, Qbasic for data conversions. A mix of Hardware too. ASCII Table , New Number to Words/66 digits , AS/400(v5r2) VB6 Viewer/Ask for code(ODBC) ^ What Is Transferring? , Check your Ports #Perfect Passwords , *Slide Bar Example , Logoff, Restart, Shut-Down PC *Keep Form On Top , Opaque Form ^ Create Objects at Run Time @ Check Key Caps Locks # GetTickCount(System Up Time) * Convert text to Excel & Collected Icons + Resize: Form/Text box ^ PC GateWay via Shell $ Drag & Drop Game ! PopUpMenu *Print File/no Open # Timer on Mult Forms ~ Splash & Mult Forms & Lots of Comments + Random/Timer/Guess * Dec >Hex >Oct >Bin % Get MAC (NIC) < saving to Registry > Wookiee Cookies \ BackUpDisk / World Conection SpeedTest $ Glossary Commonly Used Terms # phonetic list @ Detailed Computer Scan
When posting Code, Use tags.. [CODE] *Your Code* [/CODE]
Jan 6th, 2007, 10:45 PM
#6
Fanatic Member
Re: Creating Control Arrays During Runtime
Complete Code. The same could be used for Text boxes, Labels, etc...
Attached Files
Alpha Micro: Alpha Basic, AS400 V5r2, EDI (Trusted Link/ Inovis.com),Access AS/400 via VB6, Qbasic for data conversions. A mix of Hardware too. ASCII Table , New Number to Words/66 digits , AS/400(v5r2) VB6 Viewer/Ask for code(ODBC) ^ What Is Transferring? , Check your Ports #Perfect Passwords , *Slide Bar Example , Logoff, Restart, Shut-Down PC *Keep Form On Top , Opaque Form ^ Create Objects at Run Time @ Check Key Caps Locks # GetTickCount(System Up Time) * Convert text to Excel & Collected Icons + Resize: Form/Text box ^ PC GateWay via Shell $ Drag & Drop Game ! PopUpMenu *Print File/no Open # Timer on Mult Forms ~ Splash & Mult Forms & Lots of Comments + Random/Timer/Guess * Dec >Hex >Oct >Bin % Get MAC (NIC) < saving to Registry > Wookiee Cookies \ BackUpDisk / World Conection SpeedTest $ Glossary Commonly Used Terms # phonetic list @ Detailed Computer Scan
When posting Code, Use tags.. [CODE] *Your Code* [/CODE]
Jan 6th, 2007, 10:47 PM
#7
Thread Starter
Hyperactive Member
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width