Name Generator v1.1.1
Submitted By:
cjd
Rating:
(Not rated) (
Rate It)
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form NameGen
BorderStyle = 1 'Fixed Single
ClientHeight = 1575
ClientLeft = 2925
ClientTop = 1935
ClientWidth = 2310
Icon = "NameGen.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 1575
ScaleWidth = 2310
StartUpPosition = 2 'CenterScreen
WhatsThisHelp = -1 'True
Begin MSComDlg.CommonDialog CommonDialog1
Left = 1200
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
DefaultExt = "txt"
DialogTitle = "Database"
Filter = "*.txt"
InitDir = "app.path + Databases"
End
Begin VB.OptionButton optRan
Caption = "A,S,D"
Height = 255
Left = 1320
TabIndex = 5
Top = 1080
Width = 735
End
Begin VB.CommandButton cmdNextName
Caption = "&Next Name"
Default = -1 'True
Height = 375
Left = 120
TabIndex = 0
ToolTipText = "Picks another name from the database"
Top = 120
Width = 975
End
Begin VB.OptionButton opt123
Caption = "A,B,C"
Height = 255
Left = 1320
TabIndex = 4
Top = 720
Width = 735
End
Begin VB.CommandButton Command1
Caption = "&Database..."
Height = 375
Left = 120
TabIndex = 1
Top = 600
Width = 975
End
Begin VB.TextBox lblTipText
Height = 285
Left = 1200
TabIndex = 3
Top = 120
Width = 975
End
Begin VB.CommandButton cmdOK
Cancel = -1 'True
Caption = "E&xit"
Height = 375
Left = 120
TabIndex = 2
ToolTipText = "Exits the generator"
Top = 1080
Width = 975
End
End
Attribute VB_Name = "NameGen"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' The in-memory database of tips.
Dim Tips As New Collection
' Name of tips file
Const Names = "Names.TXT"
' Index in collection of tip currently being displayed.
Dim CurrentName As Long
Private Sub DoNextName()
CurrentName = CurrentName + 1
If Tips.Count < CurrentName Then
CurrentName = 1
End If
' Show it.
NameGen.DisplayCurrentTip
End Sub
Function LoadTips(sFile As String) As Boolean
Dim NextTip As String ' Each name read in from file.
Dim InFile As Integer ' Descriptor for file.
' Obtain the next free file descriptor.
InFile = FreeFile
' Make sure a file is specified.
If sFile = "" Then
LoadTips = False
Exit Function
End If
' Make sure the file exists before trying to open it.
If Dir(sFile) = "" Then
LoadTips = False
Exit Function
End If
' Read the collection from a text file.
Open sFile For Input As InFile
While Not EOF(InFile)
Line Input #InFile, NextTip
Tips.Add NextTip
Wend
Close InFile
' Display a tip at random.
DoRanName
LoadTips = True
End Function
Private Sub chkLoadTipsAtStartup_Click()
' save whether or not this form should be displayed at startup
SaveSetting App.EXEName, "Options", "Show Tips at Startup", chkLoadTipsAtStartup.Value
End Sub
Private Sub cmdNextName_Click()
If opt123 = True Then
DoNextName
Else
DoRanName
End If
End Sub
Private Sub cmdOK_Click()
Unload Me
End Sub
Public Sub Command1_Click()
Dim numindbase As Long
numindbase = Tips.Count 'count the database
If numindbase <> 0 Then
Do
Tips.Remove (1)
numindbase = Tips.Count
Loop Until numindbase = 0
End If
namefinder
LoadTips (namefile)
cmdNextName.SetFocus
End Sub
Public Sub Form_Load()
namefinder
Dim ShowAtStartup As Long
' Seed Rnd
Randomize
optRan = True
' Read in the names file and display a name at random.
LoadTips (namefile)
End Sub
Public Sub DisplayCurrentTip()
If Tips.Count > 0 Then
lblTipText.Text = Tips.Item(CurrentName)
End If
End Sub
Private Sub DoRanName()
' Select a name at random.
CurrentName = Int((Tips.Count * Rnd) + 1)
' Show it.
NameGen.DisplayCurrentTip
End Sub