如何用VB编写一个生成文本的小程序
如何用VB编写一个生成指定内容的文本的小程序比如输入4位数1234,点击按钮后在指定目录生成一个1234按不同顺序排列的数组的TXT文本(1234,1243,1324.。...
如何用VB编写一个生成指定内容的文本的小程序
比如输入4位数 1234,点击按钮后在指定目录生成一个1234按不同顺序排列的数组的TXT文本(1234,1243,1324.。。)给个详细的代码。 展开
比如输入4位数 1234,点击按钮后在指定目录生成一个1234按不同顺序排列的数组的TXT文本(1234,1243,1324.。。)给个详细的代码。 展开
2个回答
展开全部
'用法:: AA "1234"
Function AA(ByVal x As String) As String
Dim ns As Integer
ns = Len(x)
Dim n() As String
Dim w() As Integer
ReDim n(ns)
ReDim w(ns)
Dim i As Integer
For i = 1 To ns
n(i) = Mid(x, ns - i + 1, 1)
Next
Dim str As String
BB n, w, 0, str
MsgBox str
Open "c:\1.txt" For Output As #1 ''输出文件句自己改
Print #1, str
Close #1
End Function
Function BB(ByRef n() As String, w() As Integer, ByVal k As Integer, s As String)
Dim i As Integer, j As Integer
Dim b As Boolean
For i = 1 To UBound(n)
b = False
For j = 1 To k
If i = w(j) Then
b = True
Exit For
End If
Next
If Not b And k + 1 <= UBound(n) Then
w(k + 1) = i
BB n, w, k + 1, s
End If
Next
If UBound(w) = k Then
For i = 1 To UBound(w)
s = s & n(w(i))
Next
s = s & vbCrLf
Exit Function
End If
End Function
Function AA(ByVal x As String) As String
Dim ns As Integer
ns = Len(x)
Dim n() As String
Dim w() As Integer
ReDim n(ns)
ReDim w(ns)
Dim i As Integer
For i = 1 To ns
n(i) = Mid(x, ns - i + 1, 1)
Next
Dim str As String
BB n, w, 0, str
MsgBox str
Open "c:\1.txt" For Output As #1 ''输出文件句自己改
Print #1, str
Close #1
End Function
Function BB(ByRef n() As String, w() As Integer, ByVal k As Integer, s As String)
Dim i As Integer, j As Integer
Dim b As Boolean
For i = 1 To UBound(n)
b = False
For j = 1 To k
If i = w(j) Then
b = True
Exit For
End If
Next
If Not b And k + 1 <= UBound(n) Then
w(k + 1) = i
BB n, w, k + 1, s
End If
Next
If UBound(w) = k Then
For i = 1 To UBound(w)
s = s & n(w(i))
Next
s = s & vbCrLf
Exit Function
End If
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询