pingfan5888 发表于 2012-7-11 15:13:49

[已解决] 列表框读取TXT文本,不对应列,请教大大们。谢谢。

本帖最后由 pingfan5888 于 2012-7-11 15:57 编辑

列表框读取TXT文本,不对应列,请教大大们。谢谢。#NoTrayIcon

#include <GuiListView.au3>
#include<array.au3>
#Include <File.au3>
GUICreate("测试", 560, 320)
$ListView1 = GUICtrlCreateListView('IP                           |端口   |类型   |所在地区       |测试连接|||', 5, 5, 550, 300)
GUISetState()
_ld()

While 1
        If GUIGetMsg() = -3 Then Exit
WEnd

Func _ld()
        _GUICtrlListView_DeleteAllItems($ListView1)
        Local $str, $i, $dt, $aArray1
        _FileReadToArray(@ScriptDir & "\wz.txt",$aArray1)
       
        If @error Then Return MsgBox(48, 0, '错误')
        For $i = 1 TO UBOUND($aArray1) - 1
                $str = StringSplit($aArray1[$i], "$$")
                $wz = $str
                $dk = $str
                $lx = $str
                $dq = $str
               

                $dt = $wz & '|' & $dk & '|' & $lx & '|' & $dq
                GUICtrlCreateListViewItem($dt, $ListView1)
        Next
EndFunc   ;==>_ld
wz.txt如下:95.215.48.129$$8080$$透明$$乌克兰
91.121.167.167$$3128$$透明$$法国
118.96.123.8$$8080$$透明$$印度尼西亚
95.82.78.4$$8080$$透明$$伊朗
113.106.194.219$$82$$高度匿名$$广东省惠州市 电信
186.46.121.42$$8080$$透明$$厄瓜多尔
217.151.158.88$$80$$透明$$德国
150.162.76.107$$80$$透明$$巴西 圣卡塔琳娜大学
202.104.22.42$$28709$$透明$$广东省佛山市南海区 电信
193.116.157.195$$80$$高度匿名$$英国
180.249.132.65$$8080$$透明$$印度尼西亚我自己试的代码,端口跑到类型列去了,地区的列没有内容,请教大大们,哪出错了。谢谢。

user3000 发表于 2012-7-11 15:29:32

回复 1# pingfan5888


    我晕倒了.
上个提问帖里, 你直接把'$$'换成'|'不就可以直接导入数据了吗?
http://www.autoitx.com/forum.php?mod=viewthread&tid=33405&highlight=

无语了.

pingfan5888 发表于 2012-7-11 15:57:03

回复 2# user3000


    嘿嘿,真是不好意思啊,我自己也找到原因了。


谢谢。

lpxx 发表于 2012-7-11 17:09:37

很基础的东西,要多实践一下,帮你修改了一下。

#NoTrayIcon

#include <GuiListView.au3>
#include<array.au3>
#include <File.au3>
GUICreate("测试", 560, 320)
$ListView1 = GUICtrlCreateListView('IP                           |端口   |类型   |所在地区       |测试连接|||', 5, 5, 550, 300)
GUISetState()
_ld()

While 1
        If GUIGetMsg() = -3 Then Exit
WEnd

Func _ld()
        _GUICtrlListView_DeleteAllItems($ListView1)
        Local $str, $i, $dt, $aArray1
        _FileReadToArray(@ScriptDir & "\wz.txt", $aArray1)
        _ArrayDisplay($aArray1)
        If @error Then Return MsgBox(48, 0, '错误')
        For $i = 1 To UBound($aArray1) - 1
                $str = StringSplit($aArray1[$i], "$$", 1)
                $wz = $str
                $dk = $str
                $lx = $str
                $dq = $str
                $dt = $wz & '|' & $dk & '|' & $lx & '|' & $dq
                GUICtrlCreateListViewItem($dt, $ListView1)
        Next
EndFunc   ;==>_ld

xhz520 发表于 2012-7-14 17:40:23

晕。每次下都要扣钱。那有这么多钱扣

ak47gglllk 发表于 2014-9-4 09:18:47

感谢,噶写,看到这个,眼前一亮呀
页: [1]
查看完整版本: [已解决] 列表框读取TXT文本,不对应列,请教大大们。谢谢。