Private Sub btnRandom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRandom.Click
Dim Test() As String = {"Test1", "Test2", "Test3", "Test4", "Test5", "Test6"}
Dim R1 As New Random
Dim Y As Integer = R1.Next(0, Test.Length)
TextBox1.Text = Test(Y)
End Sub
Date :
2010-03-17 00:21:44
By :
msorawich
No. 2
Guest
Dim Test() As String = {"Test1", "Test2", "Test3", "Test4", "Test5", "Test6"}
'สมมุติว่ามี TextBoxt1.Text ="test1,test2,test3,test4,test5"
Dim StrText As String
StrText = TextBoxt1.Text.ToString.Split(",")
For i As Int16 = 0 To StrText.Lenght - 1
MessageBox.Show (StrText(i))
Next i
มันก็จะวนลูปแสดงค่า
test1
test2
test3
test4
test5
ส่วนคำสั่ง Random ว่าจะแสดงค่าไหนดู ลองไปคิด logic เองนะครับ
Date :
2010-03-17 13:17:12
By :
madoadza
No. 5
Guest
ผมทำได้ละเอาของพี่ 2 คนมา
ดัดแปลง
Code (VB.NET)
Dim Test() As String = Split(TextBox1.Text, ",")
Dim R1 As New Random
Dim Y As Integer = R1.Next(0, Test.Length)
MessageBox.Show(Test(Y))