Vb6 : Créeation d'une zone de texte en programmation

22max Messages postés 72 Date d'inscription vendredi 8 octobre 2004 Statut Membre Dernière intervention 16 mars 2007 - 24 mai 2005 à 01:32
yohan49 Messages postés 380 Date d'inscription samedi 22 janvier 2005 Statut Membre Dernière intervention 13 août 2011 - 24 mai 2005 à 09:12
Voila, je souhaite faire, par exemple : si var = 2 alors , créer une txtbox.
Mais je ne sais pas créer un objet en programation. D'avance, merci.
Le22


Besoin d'argent ? En s'amusant ?
http://www.prizee.com/?refer=Le22

4 réponses

jpleroisse Messages postés 1788 Date d'inscription mardi 7 novembre 2000 Statut Membre Dernière intervention 11 mars 2006 27
24 mai 2005 à 02:12
Bonsoir,

Pour essayer cet exemple, place un CommandButton et un TextBox sur ta Form.



Option Explicit

Private WithEvents txtObj As TextBox



Private Sub txtObj_Click()

MsgBox "Ceci est un TextBox ajouté de façon dynamique."

End Sub



Private Sub Command1_Click()

Dim Var

Var = Text1.Text

If Var = 2 Then

Set txtObj = Controls.Add("VB.TextBox", "txtObj")

With txtObj

.Visible = True

.Width = 1570

.Height = 375

.Text = "Bonjour"

.Top = 500

.Left = 500

End With

End If

End Sub



jpleroisse
0
cs_EBArtSoft Messages postés 4525 Date d'inscription dimanche 29 septembre 2002 Statut Modérateur Dernière intervention 22 avril 2019 9
24 mai 2005 à 08:37
Attention si tu execute deux fois ce code il plante car il faut specifier un nom d'objet different a chaque fois

i = i +1
Set txtObj = Controls.Add("VB.TextBox", "txtObj" & i)

@+


E.B.
0
yohan49 Messages postés 380 Date d'inscription samedi 22 janvier 2005 Statut Membre Dernière intervention 13 août 2011 7
24 mai 2005 à 09:10
tu peux aussi faire comme ca
sur ta forme , place un textbox nomé text1 et met lui l'index 0

private sub command1_click

dim X as integer

for X = 1 to 10
load text1(X)
text1(X).visible = true
text1(X).top = (text1(X-1).top + text1(X-1).height + 100)
next

ca creer 9 text box les une au dessus des autres espace de 100
0
yohan49 Messages postés 380 Date d'inscription samedi 22 janvier 2005 Statut Membre Dernière intervention 13 août 2011 7
24 mai 2005 à 09:12
j'me suis plante dans les parenthese :

text1(X).top = (text1(X-1).top + text1(X-1).height) + 100
0
Rejoignez-nous