例如:china_great_wall 要转换成 chinaGreatWall
请说明方法的作用及各参数表示的什么。另一个问题:String型如何转换成Int型。没用过VB,只会java。看着原来的VB程序写东西,请大家帮忙。

解决方案 »

  1.   

    Private Sub Command1_Click()
        Dim s As String
        Dim b() As String
        Dim nS As String
        s = "china great wall"
        b = Split(s, " ")
        Dim i As Integer
        For i = 0 To UBound(b)
            If i = 0 Then
                b(i) = LCase(b(i))
            Else
                b(i) = UCase(Left(b(i), 1)) & Right(b(i), Len(b(i)) - 1)
            End If
            nS = nS & b(i)
        Next i
        Debug.Print nS
    End Substring转int用cint函数
    dim s as string
    dim i as integer
    s="12"
    i=cint(s)
      

  2.   

    感谢上面的请添加注释:UBound,Left,Right,Len,及其参数的作用。
      

  3.   

    china_great_wall 要转换成 chinaGreatWall方法1:拆分拼合法
    Dim strIdentifier As String, a() As String, i As IntegerstrIdentifier = "china_great_wall"a() = Split(strIdentifier, "_")strIdentifier = LCase(a(0))
    For i = 1 To Ubound(a)
       strIdentifier = strIdentifier & UCase(a(i))
    Next i方法二:直接替换法
    Dim strIdentifier As String, tmp As StringstrIdentifier = "china_great_wall"
    tmp = LCase(Left(strIdentifier, Instr(strIdentifier, "_") - 1))
    strIdentifier = UCase(Replace(strIdentifier, "_", ""))
    strIdentifier = tmp & Right(strIdentifier, Len(tmp) + 1)