Using the Do/Loop While structure
Option Explicit
Private Sub Command1_Click()
Dim counter As Integer
counter = 1
Do
Print counter & Space$(2);
counter = counter + 1
Loop Until counter = 10
Print
End Sub
Traping Error
Option Explicit
Private Sub Command1_Click()
Dim counter As Integer
counter = 1
Do
Print counter & Space$(2);
counter = counter + 1
Loop Until counter = 10
End Sub
Traping Error
On Error GoTo ErrHandler
ErrHandler:
MsgBox Err.Description
Resume Next
ErrHandler:
MsgBox Err.Description
Resume Next
Using Visual Basic Variables
Place three text boxes , two command buttons and three labels on a form as shown in the screen shot
Copy and paste the following code
Option Explicit
Dim First As String
Dim Last As String
Dim Combined As String
Private Sub Command1_Click()
First = Text1.Text
Last = Text2.Text
Combined = First & " " & Last
Text3.Text = Combined
End Sub
Private Sub Command2_Click()
End
End Sub