Click here to Skip to main content
15,912,329 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Timer Pin
Dave Kreskowiak14-Mar-08 7:53
mveDave Kreskowiak14-Mar-08 7:53 
GeneralRe: Timer Pin
Mycroft Holmes15-Mar-08 22:11
professionalMycroft Holmes15-Mar-08 22:11 
QuestionHow Rotate a Control? Pin
Orlando_Herrera13-Mar-08 10:59
Orlando_Herrera13-Mar-08 10:59 
AnswerRe: How Rotate a Control? Pin
Christian Graus13-Mar-08 11:18
protectorChristian Graus13-Mar-08 11:18 
Questionrandom question from MS access database Pin
bapu288913-Mar-08 10:37
bapu288913-Mar-08 10:37 
GeneralRe: random question from MS access database Pin
Christian Graus13-Mar-08 11:20
protectorChristian Graus13-Mar-08 11:20 
QuestionRe: random question from MS access database Pin
bapu288916-Mar-08 8:20
bapu288916-Mar-08 8:20 
AnswerUse a collection to keep track of numbers already used Pin
David Mujica29-Mar-08 11:26
David Mujica29-Mar-08 11:26 
Here is a basic code snipet of how to use an ArrayList to keep track of your random numbers.

My application is just one form with 2 buttons and a rich text box.
Click on button1 to generate a random number, it checks if it has not been generated before, adds it to the list and displays it in the textbox. If the number already exists, a msgbox is displayed.

Button2 is used to display the current contents of the ArrayList in the debug immediate window.

<br />
Public Class Form1<br />
    Dim myNumbers As New ArrayList<br />
<br />
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
        Dim iMyRnd As Integer<br />
       <br />
        ' Initialize the random-number generator.<br />
        Randomize()<br />
        ' Generate random value between 1 and 10.<br />
        iMyRnd = CInt(Int((10 * Rnd()) + 1))<br />
<br />
        If (myNumbers.IndexOf(iMyRnd) < 0) Then<br />
            myNumbers.Add(iMyRnd)<br />
            Me.RichTextBox1.Text = Me.RichTextBox1.Text + vbCrLf + CStr(iMyRnd)<br />
        Else<br />
            MsgBox("Already generated number: " + CStr(iMyRnd))<br />
        End If<br />
    End Sub<br />
<br />
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<br />
        Dim i As Integer<br />
<br />
        For i = 0 To myNumbers.Count - 1<br />
            Debug.Print(myNumbers(i).ToString)<br />
        Next<br />
    End Sub<br />
End Class<br />

QuestionRe: Use a collection to keep track of numbers already used Pin
bapu288930-Mar-08 1:49
bapu288930-Mar-08 1:49 
GeneralNetwork communication from a mobile device to desktop [modified] Pin
Cory Kimble13-Mar-08 9:58
Cory Kimble13-Mar-08 9:58 
GeneralRe: Network communication from a mobile device to desktop Pin
nlarson1113-Mar-08 10:54
nlarson1113-Mar-08 10:54 
GeneralRe: Network communication from a mobile device to desktop Pin
Cory Kimble13-Mar-08 11:09
Cory Kimble13-Mar-08 11:09 
GeneralRe: Network communication from a mobile device to desktop Pin
nlarson1113-Mar-08 11:12
nlarson1113-Mar-08 11:12 
GeneralRe: Network communication from a mobile device to desktop Pin
Cory Kimble13-Mar-08 11:20
Cory Kimble13-Mar-08 11:20 
GeneralRe: Network communication from a mobile device to desktop Pin
nlarson1113-Mar-08 11:21
nlarson1113-Mar-08 11:21 
GeneralRe: Network communication from a mobile device to desktop Pin
Cory Kimble14-Mar-08 3:40
Cory Kimble14-Mar-08 3:40 
GeneralPage Break for report Pin
Chris Dykes13-Mar-08 9:52
Chris Dykes13-Mar-08 9:52 
GeneralRe: Page Break for report Pin
Dave Kreskowiak14-Mar-08 8:15
mveDave Kreskowiak14-Mar-08 8:15 
GeneralRe: Page Break for report Pin
Chris Dykes14-Mar-08 8:20
Chris Dykes14-Mar-08 8:20 
GeneralRe: Page Break for report Pin
Dave Kreskowiak14-Mar-08 9:50
mveDave Kreskowiak14-Mar-08 9:50 
GeneralConfused about ByVal Pin
Kevin Brydon13-Mar-08 6:19
Kevin Brydon13-Mar-08 6:19 
GeneralRe: Confused about ByVal Pin
Christian Graus13-Mar-08 9:57
protectorChristian Graus13-Mar-08 9:57 
GeneralRe: Confused about ByVal Pin
MikeMarq13-Mar-08 10:40
MikeMarq13-Mar-08 10:40 
GeneralRe: Confused about ByVal Pin
Kevin Brydon13-Mar-08 23:14
Kevin Brydon13-Mar-08 23:14 
QuestionOpening database connection Pin
johnjsm13-Mar-08 5:24
johnjsm13-Mar-08 5:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.