String str
if str的第六个字符等于1 then
  msgBox "成功"
else
    msgBox "失败"
end if如何取得字符串中某一特定的字符或字符串,如上面的例子。

解决方案 »

  1.   

    if mid(字符,6,1)="1" then 
      

  2.   


    if mid(str,6,1)="1" then
      msgBox "成功"
    else
        msgBox "失败"
    end if
      

  3.   

    mid函数
    第二个参数是位置,
    第三个参数是长度
      

  4.   

    判断str不为空怎么写,是 str <> null and str <> "" 吗?
      

  5.   

    str <> ""
    这种问题你一实践或调试就知道了。
      

  6.   

    Private Sub Form_Load()
      Dim tOutInfoTable() As String
      Dim tOutIndex As Long
      Dim tOutInfo As String
      
      tOutInfoTable() = Split("失败,成功", ",")
      
      tOutIndex = CheckInfoGetByString("KiteGl", 6) And 1
      tOutInfo = tOutInfoTable(tOutIndex)
      
      MsgBox tOutInfo
    End SubFunction CheckInfoGetByString(ByVal pString As String, Optional pStrIndex As Long = 1, Optional pCheckByte As Byte = &H6C) As Boolean
      Dim tOutBool As Long
      
      Dim tBytes() As Byte
      
      tBytes() = pString
      Dim tByteIndex As Long
      
      tByteIndex = (pStrIndex - 1) * 2
      
      tOutBool = Not CBool(pCheckByte Xor tBytes(tByteIndex))
      
      CheckInfoGetByString = tOutBool
    End Function