-1

i want to make a variable can be used in .caption, so i can get the value and used it to make something.

last experiment, i use it in foxpro and it can work pretty well. like this.

foxpro code mix variable with system

tmbl = "command"+alltrim(str(i)) set order to no_room seek (thisform.pageframe1.page1.&tmbl..caption

see the &tmbl.?? im using it as a connector to .caption

now im trying to do it in VB.NET. it can not work. i don't know what kind connector must be use in VB.NET. so can somebody please tell what must to use in VB.NET?

1 Answers1

0

You can simply use controls collection to find the control you want (and even in VFP it is the way to go, instead of abusing the & operator). Say you want to do this for a label, in C# it looks like:

var label = this.Controls.OfType<Label>()
      .SingleOrDefault(c => c.Name == "command" + i);

if (label != null)
{
   label.Text = "Whatever";
}    

Telerik code converter converts this to VB.Net as:

Dim label = Me.Controls.OfType(Of Label)().SingleOrDefault(Function(c) c.Name = "command" + i)

If label IsNot Nothing Then
    label.Text = "Whatever"
End If
Cetin Basoz
  • 22,495
  • 3
  • 31
  • 39
  • thanks Cetin Basoz.. that really help me out.. at least i can connect the text appears on my button with field on my table.. thank you very much.. i will attach the code later.. – Suyanti Jun 17 '17 at 03:29