关于Vb中字符串的比较有关问题
关于Vb中字符串的比较问题
Private Sub Command1_Click()
Dim sSection As String
Dim sKeyName As String
Dim sDefault As String
Dim sProfile As String
Dim lRetCode As Long
Dim lSize As Long
Dim Gs_SysName As String
sSection = "CONFIG"
sKeyName = "SysName"
sDefault = "0000000000000000000000000000000000000000000000000000000000000000000"
Gs_SysName = sDefault
lSize = Len(sDefault)
sProfile = App.Path & "\setup\Feq.ini"
lRetCode = GetPrivateProfileString(sSection, sKeyName, sDefault, Gs_SysName, lSize, sProfile)
Gs_SysName = Left(Trim(Gs_SysName), lRetCode)
If StrComp(Gs_SysName, sDefault) Then
MsgBox "请检查配置文件的参数值(Gs_SysName)!", vbInformation + vbOKOnly, "信息提示"
End If
End Sub
问题:Gs_SysName, sDefault两个字符串的长度都是67,而且又都是0,但不知道为什么就是不相等!困惑亚!谢谢了!
------最佳解决方案--------------------
------其他解决方案--------------------
乱猜下
len(gs_sysname)
len(sdefault)
这两个值比较看看?
------其他解决方案--------------------
lRetCode = GetPrivateProfileString(sSection, sKeyName, sDefault, Gs_SysName, lSize + 1, sProfile)
------其他解决方案--------------------
你好,可是说的更详细些吗?谢谢!
Private Sub Command1_Click()
Dim sSection As String
Dim sKeyName As String
Dim sDefault As String
Dim sProfile As String
Dim lRetCode As Long
Dim lSize As Long
Dim Gs_SysName As String
sSection = "CONFIG"
sKeyName = "SysName"
sDefault = "0000000000000000000000000000000000000000000000000000000000000000000"
Gs_SysName = sDefault
lSize = Len(sDefault)
sProfile = App.Path & "\setup\Feq.ini"
lRetCode = GetPrivateProfileString(sSection, sKeyName, sDefault, Gs_SysName, lSize, sProfile)
Gs_SysName = Left(Trim(Gs_SysName), lRetCode)
If StrComp(Gs_SysName, sDefault) Then
MsgBox "请检查配置文件的参数值(Gs_SysName)!", vbInformation + vbOKOnly, "信息提示"
End If
End Sub
问题:Gs_SysName, sDefault两个字符串的长度都是67,而且又都是0,但不知道为什么就是不相等!困惑亚!谢谢了!
------最佳解决方案--------------------
Private Sub Command1_Click()
Dim sSection As String
Dim sKeyName As String
Dim sDefault As String
Dim sProfile As String
Dim lRetCode As Long
Dim lSize As Long
Dim Gs_SysName As String
sSection = "CONFIG"
sKeyName = "SysName"
sDefault = "0000000000000000000000000000000000000000000000000000000000000000000"
Gs_SysName = Space(250)
lSize = Len(Gs_SysName)
sProfile = App.Path & "\setup\Feq.ini"
Call GetPrivateProfileString(sSection, sKeyName, sDefault, Gs_SysName, lSize, sProfile)
lRetCode = InStr(1, Gs_SysName, Chr(0))
Gs_SysName = Left(Gs_SysName, lRetCode-1)
If StrComp(Gs_SysName, sDefault) Then
MsgBox "请检查配置文件的参数值(Gs_SysName)!", vbInformation + vbOKOnly, "信息提示"
End If
End Sub
------其他解决方案--------------------
乱猜下
len(gs_sysname)
len(sdefault)
这两个值比较看看?
------其他解决方案--------------------
lRetCode = GetPrivateProfileString(sSection, sKeyName, sDefault, Gs_SysName, lSize + 1, sProfile)
------其他解决方案--------------------
你好,可是说的更详细些吗?谢谢!