Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing an array of textboxes
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00213215
Message ID:
00214408
Vues:
21
Thanks for your help.

>>I am trying to pass an array of textboxes. What am I doing wrong...
>>
>>Sub changetextcolor(textboxname() As TextBox)
>>     textboxname(1).BackColor = RGB(255, 0, 0)
>>    textboxname(2).BackColor = RGB(0, 255, 0)
>>End Sub
>>Private Sub Command1_Click()
>>    Dim txtbxs(2) As TextBox
>>    txtbxs(0) = Me.Text1
>>    txtbxs(1) = Me.Text2
>>    Call changetextcolor(txtbxs())
>>End Sub
>>
>
>You need to assign the object reference to your txtbxs array using the "Set" command. Also a minor bug in that your array elements don't match.
>
>
>Sub changetextcolor(textboxname() As TextBox)
>    textboxname(0).BackColor = RGB(255, 0, 0)
>    textboxname(1).BackColor = RGB(0, 255, 0)
>End Sub
>Private Sub Command1_Click()
>    Dim txtbxs(2) As TextBox
>    Set txtbxs(0) = Me.Text1
>    Set txtbxs(1) = Me.Text2
>    Call changetextcolor(txtbxs())
>End Sub
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform