处理IniRead读取的结果,如何把空的去掉?
$1=IniRead(@ScriptDir&"\ini.ini","1","1","")$2=IniRead(@ScriptDir&"\ini.ini","1","2","")
$3=IniRead(@ScriptDir&"\ini.ini","1","3","")
$4=IniRead(@ScriptDir&"\ini.ini","2","1","")
$5=IniRead(@ScriptDir&"\ini.ini","2","2","")
$6=IniRead(@ScriptDir&"\ini.ini","2","3","")
MsgBox(0,"如何去掉空的数据?",$1&"/"&$2&"/"&$3&"/"&$4&"/"&$5&"/"&$6)
MsgBox(0,"去掉空的数据的效果:",$1&"/"&$2&"/"&$4&"/"&$6)ini内容:
1=123
2=456
3=
1=789
2=
3=321 读取数据后很简单的判断一下就行了。
$iSectionName = IniReadSectionNames("test.ini")
$temp2 = ""
$temp1 = ""
For $i=0 To $iSectionName-1
For $j=1 To 3
$rStr = IniRead("test.ini",$iSectionName[$i+1],$j,"")
If $rStr <> "" Then
$temp2 &= $rStr &@CRLF
EndIf
$temp1 &= $rStr &@CRLF
Next
Next
MsgBox (0,"效果","如何去掉空的数据?"&@CRLF &$temp1&@CRLF&"去掉空的数据的效果:"&@CRLF&$temp2)
每锻数据要用"/"分开的啊 回复 3# jinhao
你改一下分隔符就可以了 帮你再改一改,用“/”分开
$iSectionName = IniReadSectionNames("test.ini")
$temp2 = ""
$temp1 = ""
For $i=0 To $iSectionName-1
For $j=1 To 3
$rStr = IniRead("test.ini",$iSectionName[$i+1],$j,"")
If $rStr <> "" Then
$temp2 &= $rStr &"/"
EndIf
$temp1 &= $rStr &"/"
Next
Next
$temp1 = StringTrimRight($temp1,1)
$temp2 = StringTrimRight($temp2,1)
MsgBox (0,"效果","如何去掉空的数据?"&@CRLF &$temp1&@CRLF&@CRLF&"去掉空的数据的效果:"&@CRLF&$temp2) :face (12):
页:
[1]