通过VB实现将Text 1文档的内容单行提取并保存到Text2中
答案:1 悬赏:0 手机版
解决时间 2021-04-08 02:47
- 提问者网友:贪了杯
- 2021-04-07 11:11
通过VB实现将Text 1文档的内容单行提取并保存到Text2中
最佳答案
- 五星知识达人网友:上分大魔王
- 2021-04-07 12:17
Private GetTxtPath As String
Private WriteTxtPath As String
Private strColNum As Integer
Private Sub Command1_Click()
Dim s As String
Dim col_t As Integer
Call DrawFlex
col_t = 0
MSHFlex1.Rows = MSHFlex1.Rows + 1
MSHFlex1.TextMatrix(1, 0) = 1
Open GetTxtPath For Input As #1
Do Until EOF(1)
Input #1, s
MSHFlex1.TextMatrix(MSHFlex1.Rows - 1, col_t + 1) = s
col_t = col_t + 1
If col_t = strColNum - 1 Then
col_t = 0
MSHFlex1.Rows = MSHFlex1.Rows + 1
MSHFlex1.TextMatrix(MSHFlex1.Rows - 1, col_t) = MSHFlex1.Rows - 1
End If
DoEvents
Loop
Close #1
End Sub
Private Sub Form_Initialize()
GetTxtPath = App.Path & "\1.txt"
WriteTxtPath = App.Path & "\2.txt"
End Sub
Private Sub DrawFlex()
Dim i As Long
strColNum = CInt(txtColNum.Text)
'MSHFlexGrid1控件--MSHFlex1
With MSHFlex1
.Rows = 1
.Cols = strColNum
.TextMatrix(0, 0) = "记录行"
.ColWidth(0) = 840
For i = 1 To strColNum - 1
.TextMatrix(0, i) = "字段" & i
.ColWidth(i) = 1500
Next
For i = 0 To .Cols - 1
.ColAlignment(i) = 4
Next i
.ColAlignmentFixed = 3
End With
End Sub
Private Sub MSHFlex1_Click()
Dim strCol As String
Dim i As Integer
For i = 1 To strColNum - 1
strCol = MSHFlex1.TextMatrix(MSHFlex1.Row, i)
Open WriteTxtPath For Append As #1
Print #1, strCol
Close #1
Next
MsgBox "写入成功!", vbInformation, "提示"
End Sub
Private WriteTxtPath As String
Private strColNum As Integer
Private Sub Command1_Click()
Dim s As String
Dim col_t As Integer
Call DrawFlex
col_t = 0
MSHFlex1.Rows = MSHFlex1.Rows + 1
MSHFlex1.TextMatrix(1, 0) = 1
Open GetTxtPath For Input As #1
Do Until EOF(1)
Input #1, s
MSHFlex1.TextMatrix(MSHFlex1.Rows - 1, col_t + 1) = s
col_t = col_t + 1
If col_t = strColNum - 1 Then
col_t = 0
MSHFlex1.Rows = MSHFlex1.Rows + 1
MSHFlex1.TextMatrix(MSHFlex1.Rows - 1, col_t) = MSHFlex1.Rows - 1
End If
DoEvents
Loop
Close #1
End Sub
Private Sub Form_Initialize()
GetTxtPath = App.Path & "\1.txt"
WriteTxtPath = App.Path & "\2.txt"
End Sub
Private Sub DrawFlex()
Dim i As Long
strColNum = CInt(txtColNum.Text)
'MSHFlexGrid1控件--MSHFlex1
With MSHFlex1
.Rows = 1
.Cols = strColNum
.TextMatrix(0, 0) = "记录行"
.ColWidth(0) = 840
For i = 1 To strColNum - 1
.TextMatrix(0, i) = "字段" & i
.ColWidth(i) = 1500
Next
For i = 0 To .Cols - 1
.ColAlignment(i) = 4
Next i
.ColAlignmentFixed = 3
End With
End Sub
Private Sub MSHFlex1_Click()
Dim strCol As String
Dim i As Integer
For i = 1 To strColNum - 1
strCol = MSHFlex1.TextMatrix(MSHFlex1.Row, i)
Open WriteTxtPath For Append As #1
Print #1, strCol
Close #1
Next
MsgBox "写入成功!", vbInformation, "提示"
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯