如何生成组随机序列!
我想问下怎么产生2个随机序列!然后在数据库中表现呢?
和手机充值卡的卡号和密码是一样的意思!
一个表示帐号!一个表示密码!但是要让他们不能被算出来!
参考答案:效果图如下.
Imports System.Data.OleDb
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Static intNo As Integer
ListView1.GridLines = True
Dim item1 As New ListViewItem(intNo)
'Dim hashID As Hashtable
'Dim hashPassword As Hashtable
Dim rand As New Random
Label1.Text = rand.Next(***********, ***********)
Label2.Text = rand.Next(***********, ***********)
item1.SubItems.Add(Label1.Text)
item1.SubItems.Add(Label2.Text)
intNo += 1
Dim strConncetion As String = "Data Source=""..\bin\dbsuiji.mdb"";Provider=""Microsoft.Jet.OLEDB.4.0"";"
Dim mycon As New OleDb.OleDbConnection(strConncetion)
mycon.Open()
Dim sqlstr As String = "insert into db1 values('" & Label1.Text & "','" & Label2.Text & "')"
Dim mycom As New OleDb.OleDbCommand(sqlstr, mycon)
mycom.ExecuteNonQuery()
mycon.Close()
End Sub
原创呀、没有完善呢、需要加hashtable、防止出现重号.
简单的给你看下.
用vb.net做的.
参考资料: