关于循环再循环问题求高手指教
现在获取一个字符串为 192.168.0.1|Amd|9600GT|%192.168.0.1|Amd|9600GT|%192.168.0.3|Intel|GTX250|%我想将他以 IPCPU显卡 的格式写如到列表视图中
目前用$11 = "192.168.0.1|Amd|9600GT|%192.168.0.1|Amd|9600GT|%192.168.0.3|Intel|GTX250|%
"
$bb = StringTrimRight($nString,1)
$aa = StringSplit($bb,"%")
For $i = 1 To $aa
MsgBox (0, $i, $aa[$i]) ;-获得的值为 192.168.0.1|Amd|9600gt| 现在要将此结果插入到 $ListView1
;~ GUICtrlCreateListViewItem($aa[$i][$o] & '|' & $aa[$i][$o] & '|' & $aa[$i][$o] & '|' & $aa[$i][$o] , $ListView1)
Next
但貌似不正确。求高手给指点下。鄙人才接触AU3。。 建议你把自己的相关代码发完整些...
看到一两个要猜测的变量,,我想别人和我一样,会看不下去吧? 回复 1# 49666684
用了正则.
$Str = '192.168.0.1|Amd|9600GT|%192.168.0.1|Amd|9600GT|%192.168.0.3|Intel|GTX250|%'
$Test = StringRegExp($Str, '(.*?)%', 3)#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $listview, $button, $input1, $msg, $Test, $Str
Local $item
GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
GUISetBkColor(0x00E0FFFF)
$listview = GUICtrlCreateListView("列 1 |列 2|列 3", 10, 10, 200, 150);
$button = GUICtrlCreateButton("Button", 40, 170, 120, 20)
GUISetState()
$Str = '192.168.0.1|Amd|9600GT|%192.168.0.1|Amd|9600GT|%192.168.0.3|Intel|GTX250|%'
$Test = StringRegExp($Str, '(.*?)%', 3)
For $i = 0 To UBound($Test) - 1
MsgBox(0, $i + 1, $Test[$i])
$item[$i] = GUICtrlCreateListViewItem($Test[$i], $listview)
_GUICtrlListView_SetColumnWidth($listview, $i, $LVSCW_AUTOSIZE)
Next
Do
$msg = GUIGetMsg()
Select
Case $msg = $button
MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)), 2)
EndSelect
Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example
3楼这个我测试了下。。。。但如果$Str = '192.168.0.1|Amd|9600GT|%192.168.0.1|Amd|9600GT|%192.168.0.3|Intel|GTX250|%'
继续添加下去的话。也只能显示3条。为什么? 回复 4# 49666684
$Str = '192.168.0.1|Amd|9600GT|%192.168.0.1|Amd|9600GT|%192.168.0.3|Intel|GTX250|%'
$Test = StringRegExp($Str, '(.*?)%', 3)
它能匹配192.168.0.3|Intel|GTX250|%这种形式(红色部分).
也就是说只能匹配3个.
你看看第24行和第11行,再看看帮助里面的Local,数组.
页:
[1]