Voici un code bidouillé vite fait en Vb6
Le Bouton2(Command2) modifier le texte(caption) du Bouton1(1) par le texte du TextBox Text1
Private Sub Command2_Click() Dim I&, J&, A$ Open "Form1.frm" For Binary As 1 'ou le nom de ta form A = Space(LOF(1)) Get 1, , A Close 1 I = InStr(A, "Begin VB.CommandButton Command1 ") If I Then I = InStr(I, A, "Caption = """) If I Then I = I + 21 J = InStr(I, A, """") Open "Form1.frm" For Output As 1 'ou le nom de ta form Print #1, Left(A, I - 1) & Text1.Text & Mid(A, J); Close 1 End If End If End Sub
La sauvegarde est modifiée mais pas le projet en cours Si tu réenregistre ta form ou le projet, tes modifs seront perdues Si tu pouvais utiliser une méthode différente par exemple: Mettre le texte dans le Fichier "Command1.txt"
Démarrer le Programme par
Private Sub Form_Load() Dim A$ Open "Command1.txt" for Binary as 1 A=Space(Lof(1)) Get 1,,A Close 1 Command1.caption=A '...Suite de la procédure End Sub
Private Sub Command2_Click() Open "Command1.txt" for Output as 1 Print #1,Text1.text; Close 1 Command1.caption=Text1.text End Sub
Ce serait beaucoup plus propre, il n'y aurait pas à modifier le projet
|