May i ask the VBA code running order?
In button click, i put sub for clearAll infront of SearchMember. Shall VBA run all the code in clearAll and then go to run SearchMember?
Because as the result show, all the textbox are cleared.
How can i clear all the textbox first and then show data in textbox.
Here is my button click:
Sub BtnSearch_Click()
Dim memberName As String
memberName = TextBox_name.Value
clearAll
SearchMember memberName
End Sub
Here is my sub for clearAll:
Sub clearAll()
For Each ctrl In Me.Controls
Select Case TypeName(ctrl)
Case "TextBox"
ctrl.Text = ""
End Select
Next
End Sub
Here is my sub for show the result in textbox
Sub SearchMember(memberName)
For i = 1 To 10
If Sheets("member").Cells(i * 1, 1) = memberName Then
TB_Maddress.Value = Sheets("member").Cells(i * 1, 6)
TB_Mtele1.Value = Sheets("member").Cells(i * 1, 7)
End If
Next i
End Sub
how to run “clear all textbox” first, and then show data on textbox later.