求写一个VB.Net小程序

求写一个VB.Net小程序,第1张

随机生成2-5阶方阵

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim d(,) As Integer

Dim n As Integer

Dim i As Integer

Dim j As Integer

Randomize()

n = Int(4 * Rnd() + 2)

ReDim d(n, n)

Label1.Text = ""

For i = 1 To n

For j = 1 To n

d(i, j) = Int(Rnd() + 0.5)

Label1.Text = Label1.Text &d(i, j) &" "

Next

Label1.Text = Label1.Text &vbCrLf

Next

End Sub

timer的enable初始状态为false

private void button1_Click(object sender, EventArgs e)

{

timer1.Enabled = true

i = textBox1.Text.Trim().Length

}

string str = ""

int i=0

private void timer1_Tick(object sender, EventArgs e)

{

if (str.Length <i)

{

str = textBox1.Text.Trim().Substring(textBox1.Text.Trim().Length - 1) + str

}

textBox1.Text = textBox1.Text.Trim().Substring(0, textBox1.Text.Trim().Length - 1)

if (textBox1.Text.Length <= 0)

{

textBox1.Text = str

}

}

private void button2_Click(object sender, EventArgs e)

{

timer1.Enabled = false

str = ""

}

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Dim oleDbConnection1 As OleDb.OleDbConnection

Dim oledbDataAdapter As OleDb.OleDbDataAdapter

Dim oledbData As DataSet = New DataSet

Dim strConnect As String = "Provider= OraOLEDB.OracleData Source=888User ID=888Password=888"

oleDbConnection1 = New System.Data.OleDb.OleDbConnection(strConnect)

Dim strSql As String

strSql = "select *" &" from xx"

Dim oledbCommand As OleDb.OleDbCommand

oledbCommand.CommandText = strSql

oledbCommand.CommandType = CommandType.Text

oledbCommand.Connection = oleDbConnection1

oledbDataAdapter.SelectCommand = oledbCommand

oleDbConnection1.Open()

oledbDataAdapter.Fill(oledbData, "gy_bingrenxx")

oleDbConnection1.Close()

'在窗体上添加一个DataGridView控件,在这个位置加一句代码

DataGridView1.DataSource = oledbDataAdapter.Tables("gy_bingrenxx")

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8091414.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存