none
I Need Help with Visual Basic Variables RRS feed

All replies

  • Hi,

    This forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor. I will move your case to appropriate forum to seek for better support.

    Best regards,

    Joyce


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 19, 2019 5:28 AM
  • For example, you have six variables, in an array, and want random numbers between 1 and 6:

    Dim r As New Random

    Dim variables() As Integer = Enumerable.Range(1, 6).OrderBy(Function() r.Next).ToArray

     

    The six numbers are in variables(0), variables(1), …, variables(5).

    Tuesday, March 19, 2019 5:52 AM
  • Hi,

    You can randomly generated different numbers.

    generate five different numbers between 0-99:

    Public Class Form1
        Dim c As Random = New Random()
        Dim n As Integer() = New Integer(4) {}
        Dim index As Integer() = New Integer(4) {}
    
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim s As String = ""
    
            For i As Integer = 0 To 4
                n(i) = c.Next(0, 100)
    
                For j As Integer = 0 To i - 1
    
                    If n(i) = n(j) Then
                        i -= 1
                    End If
                Next
            Next
    
            For i As Integer = 0 To n.Length - 1
                s = s & n(i).ToString() & ","
            Next
    
            MsgBox(s.Substring(0, s.Length - 1))
        End Sub
    
    End Class

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 19, 2019 6:23 AM