Home > Software engineering >  New input export TXT for help
New input export TXT for help

Time:09-20

Select output TXT path
TXT form of input: each row of X, Y, Z
Select export TXT path
TXT form for export: each row of X, Y, Z

CodePudding user response:

Fyi:
 Set fs=CreateObject (" Scripting. FileSystemObject ") : _ 
Set a=fs. CreateTextFile (" c: \ alltext TXT ", True) : _
Aleem walji riteLine (CStr (X) + ", "+ CStr (Y) +", "+ CStr (Z) : _
A.C lose: _
Set a=Nothing: _
Set the fs=Nothing: _

CodePudding user response:

The teacher look at me this, how can I read this file to change
 Private Sub Command1_Click () 

With CommonDialog1
. DialogTitle="please select a file"
. The Filter="text file | *. TXT"
. CancelError=False
. ShowOpen
Text1) Text=) FileName
End With

Dim STR As String
Dim As Double B
Dim As Double L
Dim H As Double
Dim canshu1 As Double
Dim canshu2 As Double

Open "Filer For Input As # 1
Do Until EOF (1)
The Line Input # 1, STR
Canshu1=InStr (STR, ", ")
B=Mid (STR, 1 x1-1)
Canshu2=InStr (x1 + 1, STR, ", ")
L=Mid (STR, x1 + 1, x2 - x1-1)
H=Mid (STR, x2 + 1)
Loop
Close # 1

CodePudding user response:

Teacher, I understand this may not have the above said
1. Open the TXT file path through Command1 selection
2. Then read the selected TXT file (format each row are X, Y, Z)
3. Then each row of the XYZ to function as a set of data computing
4. Save the TXT file path through Command2 selection
5. Save the format of the ditto

The small white with VB6.0 by use

CodePudding user response:

1. When using CommonDialog CancelError attribute assignment to False, 9 as above are small white;
After the CancelError set to False, in the "processing", nor the return value judgment, 100% is small white!
If the CancelError set to False, after the "dialog" return, you must determine whether the FileName attribute value is empty string!
Suggest the building Lord see a recent post in this BBS:
http://bbs.csdn.net/topics/392164300

2. The "open file" statement of you write wrong!
Open "Filer For Input As # 1 the result is" Open "in the current directory in the file named Filer",
The "open file", to the public before the dialog box to return the result without any direct association;
Because it is "Input" mode to open the file, the file does not exist when still can cause a runtime error,
Should be Open CommonDialog. The FileName For Input As # 1

3. If you read the file data, to ensure "format is correct, specification,"
So "split data needn't so much Instr, Mid function to handle, such as
Dim arrData () as string
.....
Open......
Do
The line Input # 1, STR
If (" "=STR) Then Exit the Do
ArrData=(STR, ", "https://bbs.csdn.net/topics/Split
........
This time, arrData (0) to arrData (2), each line is the corresponding X, Y, Z "string data values,


Temporary don't want to say... To modify the code yourself,

CodePudding user response:

reference 4 floor Chen8013 response:
1. When using CommonDialog CancelError attribute assignment to False, 9 as above are small white;
After the CancelError set to False, in the "processing", nor the return value judgment, 100% is small white!
If the CancelError set to False, after the "dialog" return, you must determine whether the FileName attribute value is empty string!
Suggest the building Lord see a recent post in this BBS:
http://bbs.csdn.net/topics/392164300

2. The "open file" statement of you write wrong!
Open "Filer For Input As # 1 the result is" Open "in the current directory in the file named Filer",
The "open file", to the public before the dialog box to return the result without any direct association;
Because it is "Input" mode to open the file, the file does not exist when still can cause a runtime error,
Should be Open CommonDialog. The FileName For Input As # 1

3. If you read the file data, to ensure "format is correct, specification,"
So "split data needn't so much Instr, Mid function to handle, such as
Dim arrData () as string
.....
Open......
Do
The line Input # 1, STR
If (" "=STR) Then Exit the Do
ArrData=(STR, ", "https://bbs.csdn.net/topics/Split
........
This time, arrData (0) to arrData (2), each line is the corresponding X, Y, Z "string data values,


Temporary don't want to say... To modify the code yourself,

Really sweat, had not learned, directly on the handwritten, baidu has problem, and the teacher the assignment, can't
How do I output in the specified path to the format of the specified
I write is not hair came up,,,

CodePudding user response:

CancelError=False, judge whether the FileName attribute is empty just isn't enough, also need before ShowOpen, the FileName attribute is set to an empty string, or the last selected file will in the next time to cancel the operation of the output,

Try to know:
 Private Sub Command1_Click () 
With CommonDialog1

'. The FileName="". ShowOpen
MsgBox. FileName
End With
End Sub
select files for the first time, second time click the cancel button,

CodePudding user response:

CodePudding user response:

refer to 6th floor of123 response:
CancelError=False, only whether the FileName attribute is empty is not enough, also need before ShowOpen, the FileName attribute is set to an empty string, or the last selected file will in the next time to cancel the operation of the output,

Try to know:
 Private Sub Command1_Click () 
With CommonDialog1

'. The FileName="". ShowOpen
MsgBox. FileName
End With
End Sub
select files for the first time, second time click the cancel button,

Has this thing?
But I am never CancelError=False, which USES CancelError=False, when encounter problems can also be found,

And in my own program, may no longer use this control, encapsulated with the API interface function,
  •  Tags:  
  • VBA
  • Related