0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VB.netで乱数を生成

Last updated at Posted at 2020-09-15

VB.netで乱数を生成して、テキストボックスに文字列化するコード

    Sub GenRandom()
        Dim si As String = ""
        Dim n As Integer
        For n = 0 To 6 - 1
            Dim i As Integer = r.Next(10)
            si &= i.ToString()
        Next
        TextBox1.Text = si


        Dim arrayLarge() As String = {"A", "B", "C", "D", "E", "F", "G", "H",
                                        "I", "J", "K", "L", "M", "N", "O", "P",
                                        "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
        Dim sl As String = ""
        For n = 0 To 5 - 1
            Dim c As Integer = r.Next(26)
            sl &= arrayLarge(c)
        Next
        TextBox2.Text = sl

        Dim arraySmall() As String = {"a", "b", "c", "d", "e", "f", "g", "h",
                                        "i", "j", "k", "l", "m", "n", "o", "p",
                                        "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
        Dim ss As String = ""
        For n = 0 To 5 - 1
            Dim c As Integer = r.Next(26)
            ss &= arraySmall(c)
        Next
        TextBox3.Text = ss
    End Sub
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?