MACRO LIBRARY

Lesson 1.9 homework start

Free public access. No account or subscription required.

Files

Lesson 1.9 homework start

Code

Module: HW1_91

'Homework 1.9 - incomplete
'This code is intended to reverse the text displayed in the label. Use debugging tools such _
    as break points to help determine what code is incorrect. (Hint: there are 3 mistakes)
Sub main()
    UserForm1.Show
End Sub

User form: UserForm1

Dim strText As String
Dim strRevText As String
Dim intLength As Integer
Dim intPosition As Integer
Dim i As Integer
    
Private Sub cmdReverse_Click()
    strText = lblText.Caption
    intLength = Len(strText)
    intPosition = intLength
    strRevText = ""
    For i = 0 To intLength
        strRevText = strRevText & Mid(strText, intPosition, 1)
        intPosition = intLength + i
    Next i
    lblWords.Caption = strRevText
End Sub