vb.net组合 vbnet doevent

VB.NET 列举组合的代码如何写?急!基本的算法如下:
Class Program
Shared Sub Main()
Combine(Enumerable.Range(1, 8).ToArray(), 5)
End Sub
Private Shared Sub Combine(a() As Integer, n As Integer)
combine(a, 0, n, New Integer(n - 1){})
End Sub
Private Shared Sub combine(a() As Integer, m As Integer, n As Integer, b() As Integer)
If n=0 Then
For Each i As Integer In b
Console.Write(i" ")
Next i
Console.WriteLine()
Return
End If
For i As Integer = m To a.Length-n
b(b.Length-n) = a(i)
combine(a, i+1, n-1, b)
Next i
End Sub
End Class
你的题目中排列的是字符串,那吧Integer数组改成String数组就可以了 , 通过InputBox输入后可以用"xxx,xxx".Split(",")来分隔成String数组,结果要在TextBox显示 , 可以把这个代码中的Console.Write换成追加到全局变量,再显示到TextBox就行 。自己改造一下吧 。
VB.NET组合键直接设置貌似不行可以在窗体的 KeyDown事件里面写Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("快捷键设置成功")
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.Shift And e.KeyCode = Keys.C Then
Button1_Click(sender, e)
End If
End Sub
End Class
vb.net 排列组合 代码第一题:
不需要任何控件,代码如下:
Private Sub Form_Click()
Dim A() As Integer, N As Integer
Dim St As String, I As Integer, J As Integer
Randomize
Do
St = InputBox("数字vb.net组合的个数", "输入", Int(Rnd * 100))
If St = "" Then
MsgBox "请输入数字!"
Else
【vb.net组合 vbnet doevent】N = Int(Val(St))
If N1 Then
MsgBox "请输入大于0的数字!"
Else
Exit Do
End If
End If
Loop
ReDim A(N)
For I = 1 To N
Do
St = InputBox("第" + Str(I) + "个数字", "输入", Int(Rnd * 100))
If St = "" Then
MsgBox "请输入数字!"
Else
A(I) = Int(Val(St))
Exit Do
End If
Loop
Next
For I = 1 To N - 1
For J = I + 1 To N
If A(I)A(J) Then
A(0) = A(I)
A(I) = A(J)
A(J) = A(0)
End If
Next
Next
For I = 1 To N
Open App.Path"\"Trim(Str(I))".txt" For Output As #1
Print #1, A(I)
Close #1
Next
Print "已经把"; N; "个数写入到"; App.Path; "\1.txt 到 "; N; ".txt中.请查看."
End Sub
'已经运行过.
第二题:
DIM 是变量声明语句,它的格式为:
dim 变量名[as 格式] [,变量名[as 格式][,变量名[as 格式]......]
其中:
变量名:以字母或汉字开始的字串,代表一个变量
格式有以下几种:
属于数字的有五种:
(1)字节型:byte可取值0-255
(2)整形:integer可取值-32768至32767
(3)长整形:long(可取值范围很大的正负整数)
(4)单精度型:single(可取值小数)
(5)双精度型:double(可取值范围更大,小数位数更多的小数)
字符串型:string(可代表由字母\数字或汉字组成的字符集合)
布尔型:boolean(取值为ture\false)
日期型:date(可表示形如2009-5-26 02:36这样的组合)
如果要用姓名\住址\单位名称...等用字符串型(string)
eg:dim name as string(用name变量表示名字时,声明成字符串变量)
如果是用数字需要做计算,如工资\合计\人数....等要用数字型,但有一个原则,优先选用范围小的(按照字节型(byte)\整形(integer)\长整形(long)\单精度型(single)\双精度型(double)的顺序选择),够用就可以vb.net组合了,这样可以占用内存少,运算速度快.

推荐阅读