當前位置:商標查詢大全網 - 彩票開獎 - EXCEL 在線讀取TXT文件

EXCEL 在線讀取TXT文件

將代碼改成這個:

Private?Sub?CommandButton1_Click()

Range("A3:Q8000").Clear

Dim?XmlHttp?As?Object,?tmp?As?String

Set?XmlHttp?=?CreateObject("MSXML2.XMLHTTP")

With?XmlHttp

.Open?"GET",?"/getData/3d.TXT",?False

.send

tmp?=?.responsetext

End?With

Dim?arr,?s,?brr(),?t?As?String

arr?=?Split(tmp,?Chr(10))

ReDim?brr(0?To?UBound(arr))

For?i?=?0?To?UBound(arr)

If?Len(arr(i))?>?0?Then

s?=?Split(arr(i),?"?")

For?j?=?0?To?4

t?=?t?&?s(j)?&?","

Next

t?=?Left(t,?Len(t)?-?1)

brr(i)?=?t

t?=?""

End?If

Next

Cells(2,?1)?=?"開獎期號"

Cells(2,?2)?=?"開獎日期"

Cells(2,?3)?=?"開"

Cells(2,?4)?=?"獎"

Cells(2,?5)?=?"號"

For?i?=?0?To?UBound(brr)

Cells(i?+?3,?1).Resize(1,?5)?=?Split(brr(i),?",")

Next

End?Sub