ULTRAEDIT 把文件转换成文本
发布网友
发布时间:2022-05-17 14:34
我来回答
共1个回答
热心网友
时间:2023-08-21 12:40
添加一个命令按钮和两个文本框,文本框的属性都设置为多行,加垂直滚动
将你的文件内容拷到text1中,点击按钮,text2就是你要的内容
Private Sub Command1_Click()
Dim myLine() As String, myData() As String, myTemp As String, i As Integer, j As Integer
myLine = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(myLine)
myTemp = myTemp & Mid(myLine(i), 13, 47) & " " '13为每行冒号后第一个有效字符的位置,47为每行冒号后分号前有效字符的长度,可根据实际数值更改
Next
myLine = Split(myTemp, "AA 55 ")
Text2.Text = "Dim Data422( 0 to 49 )" & vbCrLf
For i = 1 To UBound(myLine)
myData = Split(myLine(i), " ")
myTemp = "Sub Function" & i & "()" & vbCrLf & vbTab & "Data422(" & 0 & ") = " & "&HAA" & vbCrLf & vbTab & "Data422(" & 1 & ") = " & "&H55" & vbCrLf
For j = 0 To UBound(myData)
If myData(j) <> "" Then myTemp = myTemp & vbTab & "Data422(" & j + 2 & ") = " & "&H" & IIf(Left(myData(j), 1) = "0", Right(myData(j), 1), myData(j)) & vbCrLf
Next
myTemp = myTemp & "End Sub"
Text2.Text = Text2.Text & myTemp & vbCrLf
Next
End Sub