, 25,
, 30,
, 10,
, 23,
, 22,
, 31,
2,
2,
8,
, 15,
, 12,
8,
, 4,
, 27,
, 30,
, 18,
CodePudding user response:
Using the split function, give it a tryCodePudding user response:
Open "E: \ database. TXT" For Input As # 1St=""
Z=""
Do Until EOF (1)
The Line Input # 1, Z
St=St & amp; Z & amp; The first step in CRH (13) '
Loop
Close # 1
Shuzhu=Split (St., "", 1) 'step 2
Print shuzhu (0)
Print shuzhu (1)
Print shuzhu (2)
Print shuzhu (3)
Print shuzhu (4)
Print shuzhu (5)
Print shuzhu (6)
Print shuzhu (7)
Print shuzhu (8)
Print shuzhu (9)
Print shuzhu (10)
Print shuzhu (11)
Print shuzhu (12)
Print shuzhu (13)
With split function partition, some of the array is empty, and the array named an array of strings, I want to array the array but not! Consult!
CodePudding user response:
Put the software engineering in you this E dish in the same directory and run the
Private Sub Command1_Click ()
Dim Sz 'array
Dim Str 'file content
Str=OpenFile (App. Path & amp; "\ documents 1. TXT")
Str=Replace (Str, ", ", "") 'the useless digital Replace
Sz=Split (Str, vbCrLf) 'character to array
MsgBox "the first second of an array of content is:" & amp; Sz (0) & amp; "--" & amp; Sz (1)
MsgBox "array of all the content is:" & amp; VbCrLf & amp; The Join (Sz, vbCrLf)
End Sub
'┏ 〓 〓 〓 〓 〓 〓 〓 〓 〓 OpenFile, start 〓 〓 〓 〓 〓 〓 〓 〓 〓 ┓
'[abstract] :
'opens the file
The Function OpenFile (FileName, Optional ErrInfo As String) As String
'[19] mycode_id: edittime: 2012/9/5 19:48:31
On Error GoTo Err1
Dim the Fs, TextFile
Set the Fs=CreateObject (" Scripting. FileSystemObject ")
The Set TextFile=Fs. OpenTextFile (FileName)
OpenFile=TextFile.ReadAll ' 读取整个文件的信息
The Exit Function
Err1:
ErrInfo=Err. The Description
End the Function
'┗ 〓 〓 〓 〓 〓 〓 〓 〓 〓 OpenFile, end 〓 〓 〓 〓 〓 〓 〓 〓 〓 ┛
CodePudding user response:
Combination can master the upstairs, the problem is shuzhu as an array of strings, to ask how to convert it into numerical array?Private Sub Form_Click ()
Dim shuzhu () As String
St=""
Z=""
Open "E: \ \ database mantissa 01\002 \ \ database file 1. TXT" For Input As # 1
Do Until EOF (1)
The Line Input # 1, Z
St=St & amp; Z & amp; The first step in CRH (13) '
Loop
Close # 1
St=Replace (St, ", ", "") 'the useless digital Replace
Shuzhu=Split (St, CRH (13), 1)
Print shuzhu (0)
Print shuzhu (1)
Print shuzhu (2)
Print shuzhu (3)
Print shuzhu (4)
Print shuzhu (5)
Print shuzhu (6)
Print shuzhu (7)
Print shuzhu (8)
Print shuzhu (9)
Print shuzhu (10)
Print shuzhu (11)
Print shuzhu (12)
Print shuzhu (13)
End Sub
CodePudding user response:
Combination can master the upstairs, the problem is shuzhu as an array of strings, to ask how to convert it into numerical array?Private Sub Form_Click ()
Dim shuzhu () As String
St=""
Z=""
Open "E: \ \ database mantissa 01\002 \ \ database file 1. TXT" For Input As # 1
Do Until EOF (1)
The Line Input # 1, Z
St=St & amp; Z & amp; The first step in CRH (13) '
Loop
Close # 1
St=Replace (St, ", ", "") 'the useless digital Replace
Shuzhu=Split (St, CRH (13), 1) "' problem is shuzhu as an array of strings, to ask how to convert it into numerical array?
CodePudding user response:
Private Sub Command1_Click ()
Open "F: \ data. TXT" For Input As # 1
Dim shuzhu () As Single
Dim the Count As Single
The Count=0
Do Until EOF (1)
The Line Input # 1, z
ReDim Preserve shuzhu (Count) As Single
Shuzhu (Count)=CSng (Mid (z, 2, and Len (z) - 2)), 'the first method
The Count=Count + 1
St=st & amp; Z & amp; The first step in CRH (13) '
Loop
Close # 1
'shuzhu=GetData (st)' second method
Print shuzhu (0)
Print shuzhu (1)
Print shuzhu (2)
Print shuzhu (3)
Print shuzhu (4)
Print shuzhu (5)
Print shuzhu (6)
Print shuzhu (7)
Print shuzhu (8)
Print shuzhu (9)
Print shuzhu (10)
Print shuzhu (11)
Print shuzhu (12)
Print shuzhu (13)
End Sub
Private Function GetData (ByVal Data As String) As Single ()
Dim BakArr () As String
Dim DataArr () As Single
Dim I As Single
Data=https://bbs.csdn.net/topics/Replace (Data, ", ", "")
BakArr=Split (Data, CRH (13))
ReDim DataArr (UBound (BakArr)) As Single
For I=0 To UBound (BakArr) - 1
DataArr (I)=CSng (BakArr (I))
Next
GetData=https://bbs.csdn.net/topics/DataArr
End the Function