刚才突然想到这个问题因为习惯,人们大多数时候不喜欢老是先锁定大写,然后输入第一个字母,然后又换成小写,麻烦。。
我的思路是,例如Textbox中输入下列英文
hello world,i am a visual basic fans,i like visual basic.
第一个字母顶格,后面没一个单词都会有空格。我想的是先判断每一个空格后面的那个字母。然后变成大写,另外还有“,”号,也就是每个“,”号后面那个字母也变为大写,
前提是,每写一个单词必须只输入一个空格,否则给出警告。最后转换。
大家来探讨探讨。高手们给出答案~

解决方案 »

  1.   

    Text2.Text = StrConv(Text1.Text, vbProperCase)
      

  2.   


    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = 44 Then
            If Right(Text1.Text, 1) = "," Then
                KeyAscii = 0
                Exit Sub
            End If
            If Left(Right(Text1.Text, 2), 1) = "," Then
                KeyAscii = 0
                Exit Sub
            End If
        End If
        If KeyAscii = 32 Then
            If Right(Text1.Text, 1) = " " Then
                KeyAscii = 0
                Exit Sub
            End If
        End If
        If Right(Text1.Text, 1) = " " Or Right(Text1.Text, 1) = "" Or Right(Text1.Text, 1) = "," Then
            If KeyAscii >= 97 And KeyAscii <= 122 Then
                KeyAscii = KeyAscii - 32
            End If
        End If
    End Sub这个可以吗?
      

  3.   

    Private Sub Text2_KeyPress(KeyAscii As Integer)
    'MsgBox KeyAscii
    If Right(Text2, 1) = " " Or Right(Text2, 1) = "," Then
        
        If KeyAscii >= 97 And KeyAscii <= 122 Then
            KeyAscii = KeyAscii - 32
        End If
        
    End If
    End Sub
      

  4.   

    为什么不用Cooly(☆回答问题不要分儿☆) 的方法
      

  5.   

    Cooly是对的,谢谢,我也找到答案了~