How can I change a specific control, with variable .text
If Me.Controls.OfType(Of Button) = ("Button" & Bindex) Then
button.Text = PostMyresult
End If
So , no Joy, attached is the code block. Hope its not too polluted:
` Private Sub Button34_Click(sender As Object, e As EventArgs) Handles Button34.Click
Dim DaButton As String
For Bindex As Integer = 1 To 2
DaButton = ("Button" & Bindex & ".Text = SAMPLE" & Bindex)
MessageBox.Show(DaButton)
' Me.Button1.Text = "SAMPLE1"
CollectSample(DaButton & ".Text" & ".txt") 'works grabs sample from spectrum anlzr
CheckSample(DaButton & ".Text" & ".txt") 'works error check
' MessageBox.Show(SampleFlag)
If SampleFlag <> 0 Then
SendMyAvg = Math.Round(SendMyAvg, 2)
If SendMyAvg < 1 Then
MessageBox.Show("Average Sample Is < 1 ")
' Me.Button1.Text = "SAMPLE1"
For Each myCtrl As Control In Me.Controls
If (TypeOf myCtrl Is Button) Then
If myCtrl.Name = "Button" & Bindex Then
myCtrl.Text = DaButton
End If
End If
Next
Exit Sub
End If
' MessageBox.Show("Button" & Bindex & " / " & SendMyAvg)
For Each myCtrl As Control In Me.Controls
If (TypeOf myCtrl Is Label) & myCtrl.Name = "Label" & Bindex Then
myCtrl.Text = SendMyAvg
MessageBox.Show("Button" & Bindex & " / " & SendMyAvg)
End If
Next
' Button1.Text = SendMyAvg
' MsgBox("Avg Is " & SendMyAvg)
End If
Next
End Sub`
Me.Controls.OfType(Of Button)
will be a subset of the controls which are buttons. You need to iterate and find the one you want - Ňɏssa Pøngjǣrdenlarp