Bonjour,
Je voudrais savoir s'il est possible dans le genre de l'exemple qui suit :
Avec une form frmEx qui contient un bouton btnEx
Bref, je ne sais pas trop s'appelle ce que je cherche à faire (et du coup, j'ai du mal à trouver des infos dans google...) mais ce serait d'utiliser le contenu d'une variable pour accéder à un contrôle.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 Public Class frmEx Private Sub frmEx_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim str_var as String = "btnEx" Me.str_var.text = "Le text qui va bien" 'cette ligne ne compile évidemment pas End Sub End Class
Alors bien sûr, ici dans l'exemple, j'aurais pu faire Me.Controls(str_var) = "Le texte qui va bien" mais dans la pratique, le bouton ne sera pas forcément un enfant direct du contrôle form.
Ce genre de chose est-il possible ?
Merci d'avance.
P.S. : Si mes souvenirs d'école sont justes (rien n'est moins sûr), il me semble qu'en C++, si on mettait un caractère (je ne sais plus lequel) devant le nom de la variable, cela faisait ce que je cherche à faire.
P.P.S. : J'imagine que c'est un bug connu mais il semblerait que la balise codeinline ait des problèmes avec l'édition et la prévisualition des changements.
Partager