5 Attachment(s)
Male/Female Name Generator
A Simple Male and Female Name Generator. Needed: 6 Comboboxes, 2 Text Boxes, 4 Buttons, 2 Radial Buttons, and a dialog.
Screenshots are attached to this post.
Code Code:
Public Class NameGenerator
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Male1.Visible = True
Male2.Visible = True
Male3.Visible = True
MaleGenerate.Visible = True
MaleName.Visible = True
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Male1.Visible = False
Male2.Visible = False
Male3.Visible = False
MaleGenerate.Visible = False
MaleName.Visible = False
Female1.Visible = True
Female2.Visible = True
Female3.Visible = True
FemaleGenerate.Visible = True
FemaleName.Visible = True
End Sub
Private Sub MaleGenerate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MaleGenerate.Click
Male1.SelectedItem.GetType()
MaleName.AppendText(Male1.SelectedItem)
Male2.SelectedItem.GetType()
MaleName.AppendText(Male2.SelectedItem)
Male3.SelectedItem.GetType()
MaleName.AppendText(Male3.SelectedItem)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MaleName.Clear()
End Sub
Private Sub FemaleGenerate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FemaleGenerate.Click
Female1.SelectedItem.GetType()
FemaleName.AppendText(Female1.SelectedItem)
Female2.SelectedItem.GetType()
FemaleName.AppendText(Female2.SelectedItem)
Female3.SelectedItem.GetType()
FemaleName.AppendText(Female3.SelectedItem)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If RadioButton1.Checked = True Then
My.Computer.FileSystem.WriteAllText("C:\Documents and Settings\All Users\Desktop\MName.txt", MaleName.Text, True)
ElseIf RadioButton2.Checked = True Then
My.Computer.FileSystem.WriteAllText("C:\Documents and Settings\All Users\Desktop\FName.txt", FemaleName.Text, True)
End If
Dialog2.ShowDialog()
End Sub
End Class
Quote:
ComboBoxes:
Set Names to Male1, Male2, Male3, Female1, Female2, Female3.
Textboxes:
Set Names to: MaleName, FemaleName.
Buttons:
Set 2 Button Names To: MaleGenerate, FemaleGenerate.
Set Text to Same 2 Buttons to Generate.
Set other two button Text to Clear, Save
Radial Buttons:
Set Text to Male Names, Female Names.
Inital Visibilty for all items in the Form must be set at invisble. Male items will become visible when Male Names Radial is checked and vice versa for Female.
Re: Male/Female Name Generator
Looks intresting from screen shots.
Re: Male/Female Name Generator
It doesn't work! I followed your instructions but nothing happens except for the controls being visible when the code is run. Could you please upload the zipped project (minus any exe files). I am interested in how the code is supposed to work.
Re: Male/Female Name Generator
I believe the OP had hardcoded some values in the comboboxes. And that's why the code is not working.
And to get the path to Desktop or MyDocuments(which is different in XP and Vista/Win7), you could use the My.Computer.FileSystem.SpecialDirectories. For My Documents folder, it would be:
Code:
Dim strDocu as String = My.Computer.FileSystem.SpecialDirectories.MyDocuments
:wave: