Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Macro Substitution in VB
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00150101
Message ID:
00150154
Vues:
36
>>>I am a VFP developer and need to do something in VB. In VFP, doing the following is routine business:
>>>
>>>for i = 1 to 10
>>> cBox = 'text' + alltrim(str(i))
>>> thisform.&cBox..enabled = .t.
>>>next
>>>
>>>The ampersand is Macro Substitution.
>>>
>>>How to do it in VB??
>>>
>>>I posted this in the VB Forum but got negative replies. Everybody said could not be done in VB.
>>>
>>>Any body in the Fox community know how to do this in VB????
>>>
>>>TIA,
>>>Abdul Ahad
>>
>>
>>VB does not support macro substitution. You'll have write each line of code for each of the 10 textboxes.
>
>Could he not cycle through each object on the form, and set the property of those objects if they are text boxes? I know you can do this in Delphi, and I am sure it is the same in VB...

If I follow you right, you want to disable TextBoxes 1 - 10. The following VB code is an example of a form with TextBox controls and one command button. When you click the button, the code cycles through each control on the form to disable/enable any that are of the type TextBox.

Private Sub Command1_Click()
Dim MyControl As Control

With Command1
If .Caption = "Disable" Then
.Caption = "Enable"
Else
.Caption = "Disable"
End If
End With

For Each MyControl In Form1.Controls
If TypeOf MyControl Is TextBox Then
MyControl.Enabled = Not MyControl.Enabled
End If
Next

End Sub

Just let me know if you want to get more specific, such as you want to disable controls given a certain name, etc...

Regards,
Jack Mendenhall
Reinsurance Management, Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform