奇怪的有关问题 两个字符串比较的有关问题
奇怪的问题 两个字符串比较的问题
If (Int(count) > 0) Then '判断是否有这条记录
idValue = String(255, 0))
tempIdValue = String(255, 0)
For I = 1 To Int(count)
tempIdName = "id " & I
GetprivateprofileString "config ", tempIdName, " ", idValue, 255, IniPath
idValue = idValue & "s "
'tempIdValue = LCase(idValue)
tempIdValue = UserName.Text & "s "
If tempIdValue = Trim(idValue) Then
flag = 1
End If
'MsgBox InStr(UserName.Text, tempIdValue)
MsgBox tempIdValue & "@ " & idValue
MsgBox Len(tempIdValue) & "@ " & Len(idValue)
MsgBox StrComp(tempIdValue, idValue)
'MsgBox Trim(UserName.Text) & "@ "
Next
idValue 先使用string 函数
GetprivateprofileString "config ", tempIdName, " ", idValue, 255, IniPath
是从ini文件里提取他的值
tempIdValue = UserName.Text 是textbox里的值
结果明明 两个值是一样的比如 都是 fzpj 比较起来却是不相等的
我用 MsgBox tempIdValue & "@ " & idValue 显示两个值也是一样的
我以为是String(255, 0)) 的问题
用 了tempIdValue = String(255, 0) 结果还是一样
后来一用 MsgBox Len(tempIdValue) & "@ " & Len(idValue)
才发现 Len(tempIdValue) 是4 Len(idValue)是255
可能是
GetprivateprofileString "config ", tempIdName, " ", idValue, 255, IniPath
If (Int(count) > 0) Then '判断是否有这条记录
idValue = String(255, 0))
tempIdValue = String(255, 0)
For I = 1 To Int(count)
tempIdName = "id " & I
GetprivateprofileString "config ", tempIdName, " ", idValue, 255, IniPath
idValue = idValue & "s "
'tempIdValue = LCase(idValue)
tempIdValue = UserName.Text & "s "
If tempIdValue = Trim(idValue) Then
flag = 1
End If
'MsgBox InStr(UserName.Text, tempIdValue)
MsgBox tempIdValue & "@ " & idValue
MsgBox Len(tempIdValue) & "@ " & Len(idValue)
MsgBox StrComp(tempIdValue, idValue)
'MsgBox Trim(UserName.Text) & "@ "
Next
idValue 先使用string 函数
GetprivateprofileString "config ", tempIdName, " ", idValue, 255, IniPath
是从ini文件里提取他的值
tempIdValue = UserName.Text 是textbox里的值
结果明明 两个值是一样的比如 都是 fzpj 比较起来却是不相等的
我用 MsgBox tempIdValue & "@ " & idValue 显示两个值也是一样的
我以为是String(255, 0)) 的问题
用 了tempIdValue = String(255, 0) 结果还是一样
后来一用 MsgBox Len(tempIdValue) & "@ " & Len(idValue)
才发现 Len(tempIdValue) 是4 Len(idValue)是255
可能是
GetprivateprofileString "config ", tempIdName, " ", idValue, 255, IniPath