哪位大哥能帮小弟把下面代码转换VN.NET2005啊
Private Sub Command1_Click()
'To use this function with a text box, make sure the
'text box's Multiline property to True, and use the
'following code:
'-- VB functions that take strings as parameters
'will not accept a Text property.
T$ = Text1.Text
'-- Get the formatted text (45 characters wide)
Wrapped$ = WordWrap$(T$, 45)
'-- Save the text to a file.
Open "MYFILE.TXT" For Output As 1
Print #1, Wrapped$
Close #1
End Sub
Private Function WordWrap$(St$, Length)
'-- This function converts raw text into CRLF delimited lines.
Length = Length + 1
St$ = Trim$(St$)
Cr$ = Chr$(13)
Crlf$ = Chr$(13) & Chr$(10)
Do
L = Len(NextLine$)
S = InStr(St$, " ")
C = InStr(St$, Cr$)
If C Then
If L + C <= Length Then
Text$ = Text$ & NextLine$ & Left$(St$, C)
NextLine$ = ""
St$ = Mid$(St$, C + 1)
GoTo LoopHere
End If
End If
If S Then
If L + S <= Length Then
DoneOnce = True
NextLine$ = NextLine$ & Left$(St$, S)
St$ = Mid$(St$, S + 1)
ElseIf S > Length Then
Text$ = Text$ & Crlf$ & Left$(St$, Length)
St$ = Mid$(St$, Length + 1)
Else
Text$ = Text$ & NextLine$ & Crlf$
NextLine$ = ""
End If
Else
If L Then
If L + Len(St$) > Length Then
Text$ = Text$ & NextLine$ & Crlf$ & St$ & Crlf$
Else
Text$ = Text$ & NextLine$ & St$ & Crlf$
End If
Else
Text$ = Text$ & St$ & Crlf$
End If
Exit Do
End If
LoopHere:
Loop
WordWrap$ = Text$
End Function
[解决办法]
在VB2005中新建一个项目,然后进入代码模式,选择“工具”--“升级 VB6代码”即可。以下是帮你转换的:
Private Sub Command1_Click()
Dim Wrapped As String
Dim T As String
Dim Text1 As Object
'To use this function with a text box, make sure the
'text box's Multiline property to True, and use the
'following code:
'-- VB functions that take strings as parameters
'will not accept a Text property.
'UPGRADE_WARNING: 未能解析对象 Text1.Text 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
T = Text1.Text
'-- Get the formatted text (45 characters wide)
Wrapped = WordWrap(T, 45)
'-- Save the text to a file.
FileOpen(1, "MYFILE.TXT", OpenMode.Output)
PrintLine(1, Wrapped)
FileClose(1)
End Sub
Private Function WordWrap(ByRef St As String, ByRef Length As Object) As String
Dim DoneOnce As Object
Dim Text As String
Dim C As Object
Dim S As Object
Dim L As Object
Dim NextLine As String
Dim Crlf As String
Dim Cr As String
'-- This function converts raw text into CRLF delimited lines.
'UPGRADE_WARNING: 未能解析对象 Length 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
Length = Length + 1
St = Trim(St)
Cr = Chr(13)
Crlf = Chr(13) & Chr(10)
Do
'UPGRADE_WARNING: 未能解析对象 L 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
L = Len(NextLine)
'UPGRADE_WARNING: 未能解析对象 S 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
S = InStr(St, " ")
'UPGRADE_WARNING: 未能解析对象 C 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
C = InStr(St, Cr)
'UPGRADE_WARNING: 未能解析对象 C 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
If C Then
'UPGRADE_WARNING: 未能解析对象 C 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
'UPGRADE_WARNING: 未能解析对象 L 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
If L + C <= Length Then
'UPGRADE_WARNING: 未能解析对象 C 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
Text = Text & NextLine & Left(St, C)
NextLine = ""
'UPGRADE_WARNING: 未能解析对象 C 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
St = Mid(St, C + 1)
GoTo LoopHere
End If
End If
'UPGRADE_WARNING: 未能解析对象 S 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
If S Then
'UPGRADE_WARNING: 未能解析对象 S 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
'UPGRADE_WARNING: 未能解析对象 L 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
If L + S <= Length Then
'UPGRADE_WARNING: 未能解析对象 DoneOnce 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
DoneOnce = True
'UPGRADE_WARNING: 未能解析对象 S 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
NextLine = NextLine & Left(St, S)
'UPGRADE_WARNING: 未能解析对象 S 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
St = Mid(St, S + 1)
'UPGRADE_WARNING: 未能解析对象 Length 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
'UPGRADE_WARNING: 未能解析对象 S 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
ElseIf S > Length Then
'UPGRADE_WARNING: 未能解析对象 Length 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
Text = Text & Crlf & Left(St, Length)
'UPGRADE_WARNING: 未能解析对象 Length 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
St = Mid(St, Length + 1)
Else
Text = Text & NextLine & Crlf
NextLine = ""
End If
Else
'UPGRADE_WARNING: 未能解析对象 L 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
If L Then
'UPGRADE_WARNING: 未能解析对象 L 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
If L + Len(St) > Length Then
Text = Text & NextLine & Crlf & St & Crlf
Else
Text = Text & NextLine & St & Crlf
End If
Else
Text = Text & St & Crlf
End If
Exit Do
End If
LoopHere:
Loop
WordWrap = Text
End Function
'End Sub