Announcement

Collapse
No announcement yet.

Proper Case Textbox Text In Multiple Textboxes

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Proper Case Textbox Text In Multiple Textboxes



    Greetings,

    A while back someone showed me how to force Proper formatting onto the contents of a UserForm TextBox with:
    Code:
    TextBox1.Text = Application.Proper(TextBox1.Text)
    This works with one TextBox.

    When I tried to apply this to multiple TextBoxes with:
    Code:
    Sub FormatAll(iArg As Integer)
        
        Select Case iArg
            Case 1, 5, 6, 7, 9, 11, 18 'Proper Formatting
                Me.Controls("TB" & iArg & ".Text") = Application.Proper(Me.Controls("TB" & iArg & ".Text"))
            Case 2
                ....
        End Select
    End Sub
    I keep getting an error telling me that it can not find Me.Controls("TB" & iArg), which with iArg = 1 should be TB1 which is a valiid control.

    Can anyone see why debug can't see TB1 and what I can do to fix this code?

    Any help is appreciated.

    -Minitman

  • #2
    Re: Proper Textbox Formatting With Multiple Textboxes

    should be TB1 which is a valiid control
    Yes, but you have "TB1.Text". Lose the & ".Text" and use the StrConv Function


    Code:
    Sub FormatAll(iArg As Integer) 
         
        Select Case iArg 
        Case 1, 5, 6, 7, 9, 11, 18 'Proper Formatting
            Me.Controls("TB" & iArg) = StrConv(Me.Controls("TB" & iArg),vbProperCase) 
        Case 2 
            .... 
        End Select 
    End Sub

    Comment


    • #3


      Re: Proper Case Textbox Text In Multiple Textboxes

      Thanks Dave,

      That did the job.

      It's amazing how the lack of one little bit of information can ruin the whole project.

      I did not know .Text would cause so much of a problem.

      Thank you for the assistance. It is greatly appreciated.

      -Minitman

      Comment

      Working...
      X