![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
array of form controls
apparently i can't do this:
Dim TextBoxArray() As TextBox Vb.net says "cannot convert type of System.Windows.Forms.TextBox to one-dimensional array of system.windows.forms.textbox" any idea how i can get something similar to this that would look basicallly the same? thx
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 126
Rep Power: 4
![]() |
I dont exactly know a lot about this, but from my experience, when it says that, its because it wants you to specify a max.
Dim TextBoxArray(0 To 4) As Textbox in VB6 and Dim TextBoxArray(4) As Textbox in VB.NET Im not completely sure but that might be the problem. EDIT: Actually I just tried what you had, and it worked for me, so I really dont know, thats strange. |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
oh i figured it out, you have to do
Dim TextBoxArray(4) As TextBox For I as Integer = 0 To 4 TextBoxArray(I) = New TextBox Next thanks for your help you set me off in the right direction ![]()
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
if you also make a bunch of controls (text-boxes) whatever, with the SAME NAME it'll ask you if you want to create a "command array". then you can be like:
text1.item(1).text = "hello world" etc.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#5 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Quote:
|
|
|
|
|
|
|
#6 | |
|
Expert Programmer
|
Quote:
|
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
i should look into .net a little more then. today in class out teacher was explaining pass by value or reference and i was kind of freaked out about how vb handled it, where you can arbitralily decide whether to do one or the other in the function definition regardless of how the variables or objects are instantiated. my goal is to get through the rest of the vb portion of our class without it erasing any of my good habits from C/C++. shouldn't be hard though, i've only got one more homework project to do cuz i did all the other ones in the first week of class or so. hell, i don't have to do anything till late october.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#8 |
|
Newbie
Join Date: Oct 2005
Location: The othe side
Posts: 19
Rep Power: 0
![]() |
Before you can put anyting into your array
Dim TextBoxArray() As TextBox Dim TextBoxArray(5) As TextBox
__________________
Cheers Ithaqua |
|
|
|
|
|
#9 |
|
Expert Programmer
|
Not necessarily: you might want a variable amount of controls (dynamic array + redim or the arrays methods) for some strange reason. Plus it's more memory efficient (you're immediately allocating 6 empty ranges and pointers even without declaring it As New, whereas TextBoxArray() allocates next to nothing).
|
|
|
|
|
|
#10 |
|
Newbie
Join Date: Oct 2005
Location: The othe side
Posts: 19
Rep Power: 0
![]() |
Yes, when you decalre the array you dont have to dimension it, but before you can put anything in there then it will have to be a fixed length. Doing it that way will mean you have to redim the array to the approiate length before you can work in it.
__________________
Cheers Ithaqua |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|