Click here to Skip to main content
15,892,965 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to Run charmap.exe with a chosen font? Pin
Dave Kreskowiak31-Aug-13 8:27
mveDave Kreskowiak31-Aug-13 8:27 
AnswerRe: How to Run charmap.exe with a chosen font? Pin
TnTinMn2-Sep-13 5:52
TnTinMn2-Sep-13 5:52 
AnswerRe: How to Run charmap.exe with a chosen font? Pin
Marco Bertschi3-Sep-13 4:30
protectorMarco Bertschi3-Sep-13 4:30 
QuestionRandom Generator not Generating Pin
Zyndell29-Aug-13 9:55
Zyndell29-Aug-13 9:55 
SuggestionRe: Random Generator not Generating Pin
Richard MacCutchan29-Aug-13 21:17
mveRichard MacCutchan29-Aug-13 21:17 
AnswerRe: Random Generator not Generating Pin
Dave Kreskowiak30-Aug-13 2:52
mveDave Kreskowiak30-Aug-13 2:52 
AnswerRe: Random Generator not Generating Pin
Zyndell30-Aug-13 7:48
Zyndell30-Aug-13 7:48 
GeneralRe: Random Generator not Generating Pin
Dave Kreskowiak30-Aug-13 12:45
mveDave Kreskowiak30-Aug-13 12:45 
You're going to have to define "not working". What does it actually do?? Step through the code line by line and watch the variable contents.

As for moving the Random to class-level, it's easy. Oh, and you might want to break your click handler functionality down a bit into simpler methods:
Public MyForm

    ' This is declared at the class level.
    Private RNG As New Random()

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.CheckState = 1 Then
            Male()
        End If
    End Sub

    ' This code really should be in Form2, not in any other form.
    ' Form code should be responsible only for interacting with the controls
    ' on its own form, not with controls on another form.
    Private Sub Male()
        Dim lines() As String = GetLinesFromFile("male.txt")

        Form2.TextBox1.Text = lines(RNG.Next(lines.Length))
    End Sub

    Private Function GetLinesFromFile(ByVal filename As String) As string()
        return File.ReadAllLines(filename)
    End Function 

End Class


GeneralRe: Random Generator not Generating Pin
Zyndell30-Aug-13 15:03
Zyndell30-Aug-13 15:03 
AnswerRe: Random Generator not Generating Pin
Zyndell2-Sep-13 15:46
Zyndell2-Sep-13 15:46 
GeneralRe: Random Generator not Generating Pin
Dave Kreskowiak2-Sep-13 16:35
mveDave Kreskowiak2-Sep-13 16:35 
GeneralRe: Random Generator not Generating Pin
GuyThiebaut2-Sep-13 22:13
professionalGuyThiebaut2-Sep-13 22:13 
GeneralRe: Random Generator not Generating Pin
Zyndell3-Sep-13 4:17
Zyndell3-Sep-13 4:17 
GeneralRe: Random Generator not Generating Pin
GuyThiebaut3-Sep-13 4:24
professionalGuyThiebaut3-Sep-13 4:24 
GeneralRe: Random Generator not Generating Pin
Zyndell3-Sep-13 18:42
Zyndell3-Sep-13 18:42 
GeneralRe: Random Generator not Generating Pin
GuyThiebaut3-Sep-13 20:18
professionalGuyThiebaut3-Sep-13 20:18 
QuestionVB6 Datagrid Pin
jayadewa10027-Aug-13 19:52
jayadewa10027-Aug-13 19:52 
AnswerRe: VB6 Datagrid Pin
Richard MacCutchan27-Aug-13 21:01
mveRichard MacCutchan27-Aug-13 21:01 
GeneralRe: VB6 Datagrid Pin
jayadewa10027-Aug-13 21:25
jayadewa10027-Aug-13 21:25 
GeneralRe: VB6 Datagrid Pin
Richard MacCutchan27-Aug-13 21:51
mveRichard MacCutchan27-Aug-13 21:51 
AnswerRe: VB6 Datagrid Pin
Dave Kreskowiak28-Aug-13 2:19
mveDave Kreskowiak28-Aug-13 2:19 
AnswerRe: VB6 Datagrid Pin
salih19894-Sep-13 20:49
salih19894-Sep-13 20:49 
QuestionUpdate System Project Pin
10kbps27-Aug-13 0:38
10kbps27-Aug-13 0:38 
AnswerRe: Update System Project Pin
Dave Kreskowiak27-Aug-13 2:15
mveDave Kreskowiak27-Aug-13 2:15 
GeneralRe: Update System Project Pin
10kbps27-Aug-13 3:33
10kbps27-Aug-13 3:33 

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.