Common Dialog And Saving To Text File
I want to use the common dialog control to allow the user to select a path, but I want to assign the filetitle myself. Am I able to disable the filename textbox and/or put in a preselected filetitle so that the user only selects the path? Or do I need to create my own file directory?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Saving A Text File With Common Dialog
I'm making a text editor and it will be complete if i get the source code for saving a text file using the common dialog. can anyone help? this is like the last post where i asked how to open it . thanks in advance
Saving Text And Pictures Using The Common Dialog Control
Okay how would this be the best way to do this. I want to try to use the common dialog control. Okay I want to be able to save the designated label captions, textbox's, and images to one file from different forms using the commondialog control. Then, I want the user to be able to open this file and place all the label captions, textbox text's and pictures for images on they were saved. I am thinking there should be a way that the info could be split and then dispersed through the program starting from the first designated form. Any help appreciated.
Printing A Text File Using Common Dialog
Here's another question concerning the common dialog control. How do you print text files with it? i tried to do it myself but i got stuck! please help me. thanks in advance.
ps after this post ill stop spamming about common dialog
Open A Text File With Common Dialog
how do you open a text file with the common dialog control? and how do you display it on a text box? im a newb to the common dialog control.
How Can I Save A Text File Using Common Dialog
One should use Freefile function when dealing with files.
This allows the program to grab the next available number
and anyone reading the code doesn't have to remember what
number was assigned to what file. this is not necessary but
leads to good coding habits and more easily read code, especially when dealing with multiple files.
Private Sub Command1_Click()
Dim intNum as Integer
intNum = Freefile
On Error Resume Next
CommonDialog1.CancelError = True
Open CommonDialog1.Filename For Output As intNum
Print #intNum, "MyText"
Opening A Text File From Common Dialog With A Text Box.
Could someone tell me why I get
'Variable Required - cant assign to this expression'
when I try to use this code from a command button.
Private Sub Command1_Click()
.Filter = "Text File|*.txt|"
Open CommonDialog.filename For Input As #1
Do Until EOF(1) = True
Get #1, , Text1
Open Text File In Common Dialog Control
On selecting a file (text) in a common dialog control and selecting "Open" the file does not open as expected - the dialog control window closes. What am I missing?
Print A Rich Text File Without Common Dialog?
i was wondering if there was a way to print a .rtf (rich text file) without using the common dialog control, so that no dialog boxes come up.
i found some code that would print a .txt file, but it can't do rich text.
Create New Empty Text File Using Common Dialog Box, Then Save Data To It
I have read some articles and examples about Common Dialog Box to Open, Save files to disk.
1. But how to create an empty text file using Common Dialog Box control? In this case, I dont prefer command Open "xya.txt " For Output As ###. I just want to use CommonDialog Box
2. Also, I found sample of using Save . My question, if i click Save, what actually I save?
Saving With Common Dialog
Here's my code:
With CommonDialog1 'open a with statement as there is a lot of code
.DialogTitle = "Save" 'sets the dialog title
.InitDir = "C:" 'sets the initial directory
.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" 'sets the file types
.ShowSave 'show the dialog
I know that this:
Has to go in, but when I copy that directly, I get an runtime error (Object Required)
What is the RTB1.LoadFile mean? The name of my RichTextBox is "completedaccounts.text" and the common dialog box is the same (commondialog1)
What's wrong here?!
Saving Using A Common Dialog Box
I've got a save dialog box to save files from my form but have noticed a problem:
If I don't enter a filename it saves the information anyway but where it saves it I haven't got a clue!
Is there anyway I can trap this and display an appropiate message?
Saving With Common Dialog Box
To save with a common dialog box, do you use the normal "open" and "write" properties? If so what do you use for the directory name? I need some assistance on how to save using a common dialog box
Saving Images W/Common Dialog
I'm trying to save a picture in a picturebox
Private Sub mnuSave_Click()
cdlDialog.Filter = "Images (*.jpg) | *.jpg"
cdlDialog.ShowSave ' show save dialog box..cm
SavePicture picImg.Picture, cdlDialog.FileName
I'm getting error 380 "Invalid Property Value".
Saving Files Using Common Dialog
I have a collection class containing person objects, I have a clsPersonManager class which is to contain a save function to be used to print each objects values to a text file. This is what i have so far, in my main form which opens the common dialog:
Private Sub cmdSave_Click()
Dim Filenum As Integer
Dim filename As String
On Error GoTo ExitNow
CommonDialog1.Filter = "All Files (*.*)|*.*|Text files|*.txt"
CommonDialog1.FilterIndex = 2
CommonDialog1.DefaultExt = "txt"
CommonDialog1.Flags = cdlOFNHideReadOnly Or cdlOFNPathMustExist _
Or cdlOFNOverwritePrompt Or cdlOFNNoReadOnlyReturn
CommonDialog1.DialogTitle = "Select the destination File"
CommonDialog1.filename = filename
'Exit if the user presses cancel
CommonDialog1.CancelError = True
filename = CommonDialog1.filename
Dim PM As New clsPersonManager
'pass the collection and filename to the person manager
PM.Save mcolPersonCollection, filename
In the person manager i have:
Public Sub Save(col As Collection, filename As String)
'Create a loop to print all data from the objects to the text file
Dim lngCt As Long
For lngCt = 1 To col.Count
'Print data to text file
I need to know how to print the data from the objects to a file.
I've been stuck for days on this problem and would really appreciate some help.
Saving Common Dialog Color
Hi guys i have a text box that i change the color of with a common dialog control
This works fine
I then save this value to a file and want to reload it
When I load up and put this value as the backcolor it always comes out black.
Any ideas. The color value i am saving is 8454143
}...the bane of my life!
Saving Word Doc In Browser Using Common Dialog Box
I can seem to figure this out, I hope someone can help me... I am writing a simple program that will open a template word document in a web browser and enable you to edit and save it to another location. I have looked through all of the threads and I have seen the examples in MSDN but still I can't seem to get to code right in order to save the document using the common dialog box. The file opens fine, and you can edit the file, but when it comes to saving, it doesn't do anything. I think that I have the code in the wrong order or something. This is the code that I have written:
Private Sub cmdInsert_Click()
'Finds the template document to be edited
WebBrowser1.Navigate ("C:TemplateNEW WORD DOCUMENT.doc")
Open "DOCUMENT.doc" For Input As #1
Private Sub cmdSave_Click()
'Opens the Common Dialog box and sets the path for the file to be saved
.FileName = "G:Documents" & Trim(txtDocTitle) & "" 'Takes the new file name given
I appreciate any help,
Integrating Common Dialog Box With Saving MS Word
Hi, I do have a question on the common dialog box. I have a form that calls the common dialog box show open codes to open a document file. I have created another form to display the texts from the document. Is there ways to have VB to throw values (like the file name of the document to open) around the forms?
Common Dialog Saving Without Rich Textbox
Well I guess the title explains it. Anyway I am making a chat program and learning as I do it and I want the feature to save your conversations however I know how to do this with a Rich textbox, but not a normal textbox. I would much prefer the window to do the save which Common Dialog offers.
Common Dialog Box: Saving [I Screwed Up: Resolved]
I am having more proelms with saving. I have managed to save to a text file, which have writen in the code. And i know how to use a Common Dialog Box to get the FileName, but it doesnt include the file extension. I have put a filter in (shown below) can any one help? Thanks
Meltdown Software Text File (*txt)|*txt
Saving A Word Document Using Common Dialog
Hi it's been a long time,
I was wondering what is wrong with my code below?
My aim is to save a word document that i created. The user picks the directory and then i use that to save it to the location.
For some reason, it is not saving anything and it is leaving the word object open.
Can someone help me out please?
Dim exportinvoicefilepath As String Sub mnuexport_Click()On Error GoTo errorhandler savedialog.DialogTitle = "Choose location where you want to save the invoice"savedialog.CancelError = Truesavedialog.InitDir = "C:"savedialog.Filter = "Word Document (*.doc)|*.doc"savedialog.FilterIndex = 1savedialog.ShowSaveexportinvoicefilepath = savedialog.FileNameCall exportinvoiceExit Sub errorhandler:MsgBox "An error occurred during saving. Please try again", vbCritical, "Error Occurred" End Sub Sub exportinvoice() 'On Error Resume Next Set objwdapp = New Word.Application If txtinvoicetype.Text = "SI" Then Set objwddoc = objwdapp.Documents.Add("\S2websoftwareinvoiceFinalInvoice.dot") ElseIf txtinvoicetype.Text = "SC" Then Set objwddoc = objwdapp.Documents.Add("\S2websoftwareinvoiceFinalCreditNote.dot") End If objwdapp.Visible = False If txtaddress2Sl.Text <> "" And txtaddress3sl.Text = "" And txtaddress4sl.Text = "" Then objwddoc.Bookmarks("Address2").Range = txtaddress2Sl.Text objwddoc.Bookmarks("Postcode").Range = txtPostcode.Text ElseIf txtaddress2Sl.Text = "" And txtaddress3sl.Text <> "" And txtaddress4sl.Text = "" Then objwddoc.Bookmarks("Address2").Range = txtaddress3sl.Text objwddoc.Bookmarks("Address3").Range = txtPostcode.Text ElseIf txtaddress2Sl.Text = "" And txtaddress3sl.Text = "" And txtaddress4sl.Text <> "" Then objwddoc.Bookmarks("Address2").Range = txtaddress4sl.Text objwddoc.Bookmarks("Address3").Range = txtPostcode.Text ElseIf txtaddress3sl.Text <> "" And txtaddress3sl.Text <> "" And txtaddress4sl.Text = "" Then objwddoc.Bookmarks("Address2").Range = txtaddress2Sl.Text objwddoc.Bookmarks("Address3").Range = txtaddress3sl.Text objwddoc.Bookmarks("Address4").Range = txtPostcode.Text ElseIf txtaddress2Sl.Text = "" And txtaddress3sl.Text <> "" And txtaddress4sl.Text <> "" Then objwddoc.Bookmarks("Address2").Range = txtaddress3sl.Text objwddoc.Bookmarks("Address3").Range = txtaddress4sl.Text objwddoc.Bookmarks("Address4").Range = txtPostcode.Text ElseIf txtaddress2Sl.Text <> "" And txtaddress3sl.Text = "" And txtaddress4sl.Text <> "" Then objwddoc.Bookmarks("Address2").Range = txtaddress2Sl.Text objwddoc.Bookmarks("Address3").Range = txtaddress4sl.Text objwddoc.Bookmarks("Address4").Range = txtPostcode.Text ElseIf txtaddress2Sl.Text <> "" And txtaddress3sl.Text <> "" And txtaddress4sl.Text <> "" Then objwddoc.Bookmarks("Address2").Range = txtaddress2Sl.Text objwddoc.Bookmarks("Address3").Range = txtaddress3sl.Text objwddoc.Bookmarks("Address4").Range = txtaddress4sl.Text objwddoc.Bookmarks("Postcode").Range = txtPostcode.Text ElseIf txtaddress2Sl.Text <> "" And txtaddress3sl.Text = "" And txtaddress4sl.Text = "" Then objwddoc.Bookmarks("Address2").Range = txtaddress2Sl.Text objwddoc.Bookmarks("Postcode").Range = txtPostcode.Text End If Call wordcheck Set objwdrange = Nothing objwddoc.Close (exportinvoicefilepath) Set objwddoc = Nothing objwdapp.Quit (exportinvoicefilepath) Set objwdapp = Nothing End Sub
Saving Loading To Listbox Using Common Dialog
Hi all, I am a new poster to this forum. I have a problem, which I would appreciate if it would be answered. A problem I have been looking for a long time to resolve. I was/am unable to find an answer to it anywhere. Ok, here goes my problem. I need a source code, that will allow me to load and save a listbox to a ".dat" file. From a Common dialog box. So far I have not found a single line of code, anywhere, to help me with it. Any suggestions, links or anything else for me to get to the code would be appreciated. -Please
Common Dialog Save Text Boxes
I know this must be asked and answered before but my search for this paticular scenario didn't get me anywhere. Here is what I'm aiming to accomplish.
Use common dialog to do a ShowOpen and ShowSave
Loop through my controls for TypeOf textbox and write to a text file using open for random
Not sure how to piece all of that together.
I want to allow the user to save what is visible on the screen (textboxes) to an ordinary text file using the common dialog.
Thanks in advance for any help on this
Common Dialog To Save Label Or Text Box To Xml
i have a skin maker program which creates custom skins for my program. I want the program to when clicking Generate Skin to save the contents of a label (label1) to a .xml with the common dialog but i cant work out the save function for the label OR a text box. please help.
i tried using a rich text box but on my xp sp3 comp when its ticked i get an error about the reference
any help is appreciated
Text Files And Common Dialog Control
I have a program with a common dialog control to open a text file selected by the user.
Is it possible to open three text files at the same time.. So the user select all the files at the same time, only once.
Text Path, Common Dialog Problem
im having trouble with this code.
Its a command button that opens a dialog box and display the files path on text box1.
i want it to display in text box 3 so that i can show the user the path where the file will be saved with a new name.ei see.xml becomes see_new.xml
however when i click browse and click on cancel i get an error message.
.FileName = "" 'clear any previous used filenames
.Filter = "MetaData Files (*.xml)/*.xml" 'file extensions to show
.InitDir = "C:" 'default path to open
.DialogTitle = "Open MetaData Files" 'optionally you can put another title on the dialog window
If Not .FileName = "" Then txt1.Text = .FileName
--------here is where i get the error message
Dim i As Integer, s As String
i = InStrRev(txt1.Text, ".")
s = Mid(txt1.Text, 1, i - 1) & "_New" & Mid(txt1.Text, i)
txt3.Text = s
File New Common Dialog
I've seen in an application a common dialog box very similar with the Save File Common Dialog Box, but instead of the Save button it had Create button.
I want to create something similar in my app. I assume it is a parameter that I have to rename in my Common Dialog box and then call .ShowSave.
How can I rename that Button to "Create"?
Common Dialog File Name
I really hate to ask this question, but I have been searchng the form for like almost an hour and can't find the answer.
When I use commondialog1.filename it gives the full path. is there a way to justget the file name?
Thanks so much.
Parse Common Dialog File
I have a Multiselect Common dialog and I want to parse the filenames.. how do I do that ??
The filenames are separated by Nulls !!
Pls help me
Why Does Common Dialog Generate A *.cfn File?
Every time I open a file with Common dialog, a *.cfn file is generated in the same folder the project/executable lives in. The *.cfn file is just text with the follwing, "\filepathfilename
ame of executable.dft" Why is this happening?
Common Dialog - Open File
Is there a way where you can load .rtf .doc into a textbox? not a richtextbox?
Edit by Moderator: In the future, please start your own threads, don't dig up 2 year old threads. Thanks.
Common Dialog - Open File
would somebody PLEASE tell me why this code will not open a file. I read MikeJ's tutorial and I couldn't get it to work because I don't have a Rich textbox. Why do I need one? I'm trying to open any form from a File/Open menu. When I select the file, it goes into the window on the open dialog box but it just will not open. I've been step by step through two books and this forum for 3 hours with no luck. PLEASE HELP.
Private Sub FileOpen_Click()
CommonDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" 'This sets the filter for common dialog
CommonDialog1.ShowOpen 'Make common dialog show the open dialog
Open CommonDialog1.FileName For Input As #1
Save File With Common Dialog
How can i save a textbox with a common dialog so i can go the the place i want to save my file all i got so far is
CD1 = shot for CommonDialog1
Private Sub Command5_Click()
Get File Names From MS Common Dialog
I have used a Microsoft Common Dialog 6.0 control in my Visual Basic project with multi-select set to true. Now I need to call each file that was selected into a string that is being written to a text file. Each file name will be a new line in the text file. Not sure, but I think I need to use a Do/Loop to build this list of files. I used the "Open" method to open a file then the "Output" method to write to the file. The best method I can see to use is "Write" to amke the output to the file. But I am not sure how to iterate over the selcted files writing a new line for each file. Any help is greatly appreciated. Thank you.
Common Dialog For Opening A File But...
I want to have the Open File Common Dialog but i dont want it to open a file. I just want to save the path and file name of the file opened to a string. Is that possible.
If its not possible how would i go upon making a browse input box kind of thing to browse for a file and save the full path as a string?
Thanks for you help in advance.
Open File Without Common Dialog
How can I have a open file dialog without using the common dialog within VB6? I do not want to create a new form and open it, I want a real open file dialog.
How can I do this?
Common Dialog Predetermined File ?
hi , im taking a look at a file sender made by someone else , and they used common dialog to search for files to send , is there a way to illiminate this process and have a predetermined a file to send
im trying to make a small game that involves file sending back and forth , and would like to assign a command button for each of these predermined files within the game
so say the the file locations would be:
instead of using common dialog to find them , id like to have something easier like
Private Sub Command1_Click()
send file C:Program FilesOpForAnimations1
im such a noob , and im sorry for that , i just want a predetermined location rather than using common dialog manually if thats possible
Common Dialog And File Type
is there a way i can configure the common dialog to restrict the types of files. for example, i only need .txt files, only txt files will be shown instead of all.
Input A File From A Common Dialog Box
I am trying to Input a file from a common Dialog box but I am not sure of the code up to a certain point. Here is my code:
private Sub cmdEndprogram_Click()
Dim intResponse as Integer
Const conPrompt as string = "Are you sure?"
Const conTitle as string = "Quit?"
intResponse = MsgBox(conPrompt, vbYesNo + vbQuestion, conTitle)
If intResponse = vbYes then
private Sub Form_Load()
Dim problemNumber as Integer, name as string
Dim title1 as string, problemNumber1 as Integer
Dim prompt as string, title as string, question as string
Dim answer1 as string, answer2 as string
Dim answer3 as string, number as Integer
Dim leftPos as Integer, buttonWidth as Integer
Dim ControlArray as Integer, intFileNum as Integer
Dim FileName as string
prompt = "Enter your Name."
title = "Your Name"
name = InputBox(prompt, title)
'pen "DataType Quiz.txt" for input as 1
'input #1, title1, problemNumber1
'print #2, name
'print #2, title1, problemNumber1
'get the size and position of the first button.
'leftPos = cmdDisplay(0).Left
'buttonWidth = cmdDisplay(0).Width
'Do While Not EOF(1)
'input #1, problemNumber, question, answer1, answer2, answer3, number
'picOutput.print problemNumber, question
'print #2, problemNumber, question, answer1, answer2, answer3, number
'for ControlArray = 1 to problemNumber
'leftPos = leftPos + buttonWidth + 30
'cmdDisplay(ControlArray).Left = leftPos
'cmdDisplay(ControlArray).Caption = ControlArray
'cmdDisplay(ControlArray).Visible = true
Here is the file I am trying to input. I have two other files that I have to input as well, so I have to have a control array for each question so I have a command button for each question. I guess I am just asking for a example on how I input the text file from the common dialog box into the text window, one question at a time and the control array for a button for each question.
Data-types Quiz, 8
1, What data-type would you use for the population of Chicago?, LONG,LONG,lng,1
2, What data-type would you use for a Social Security number?, STRING,STRING,str,1
3, What data-type would you use for a variable where the only valid values are ON/OFF?, BOOLEAN,BOOLEAN,bln,1
4, What data-type would you use for a constant with a value for Pi?, SINGLE,SINGLE,sng,1
5, What data-type would you use for a variable to hold the grains of sand on a beach?, DOUBLE,DOUBLE,dbl,1
6, "What initial should proceed a Public variable in a module to indicate its scope?
d. No initial", B,G,"B. g",5
7, "What initial should proceed a variable that is used in a form to indicate its scope?
d. No initial", C,M,"C. M",5
8, "What initial should proceed a variable that is used in a local procedure to indicate its scope?
d. No initial", D,NO INITIAL,"D. NO INITIAL",5
*** Resolved ***Save Highlighted RTF Text Using COmmon Dialog SaveAs
A while back someone raised the question as to how to save the highlighted text to a file and several wrote and gave examples as to how this can be accomplished. However, as I remember (I can't seem to find the original post), they all used a coded file name and path.
Can anyone show me how to save the highlighted text from a RTF box to a file through the Common Dialog SaveAs so that I can give the highlighted text a filename and path?
It would be most appraciated.
Rev. Michael L. Burns
Common Dialog File Select Not Containing File Names.
i have this vb script code that i'm using in a .hta program. it basically calls a common dialog to display multiselect file list using explorer type file list.
here's the code:
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")
ObjFSO.Filter = "All Files|*.*"
ObjFSO.FilterIndex = 3
ObjFSO.InitialDir = "c:"
ObjFSO.Flags = cdlOFNAllowMultiselect or cdlOFNExplorer
InitFSO = ObjFSO.ShowOpen
selected_files = ObjFso.FileName
each_file = split(selected_files, vbnullchar)
everywhere i look at, they state that if you use this code, it should contain all the file names that you selected. but i only see the path. no file names. however if i only select one file, it will display the path and file name.
any ideas, how i can get the selected file names to show up?
Common Dialog Control To Select File The File To Use
As I am newbie at VB6 I woudl like some help on how to implement a common dialog control on my form so I can select the txt file I wish to use to bring into my array. Sorry It seems like such simple question but I would really appreciate some guidance on this? Thanks!
Input File From A Common Dialog Control
this is the code in my form:
Private Sub mnuOpen_Click()
cdlNewEmployee.Filter = "Employee Data (*.dat)|*.dat|All Files (*.*)|*.*"
cdlNewEmployee.Flags = cdlOFNHideReadOnly
cdlNewEmployee.CancelError = False
cdlNewEmployee.FileName = ""
this is the code in my module:
Public Function OpenFile()
Dim lastName As String, firstName As String, _
age As Integer, sexMale As Boolean, count As Integer
Do While EOF(1) = False
Open "EMP.DAT" For Input As #1
Input #1, lastName, firstName, age, sexMale
Call modEmployee.AddNewEmployee(lastName, firstName, age, sexMale)
when i click on the "EMP.DAT" file to be opened, a run-time error occurs saying: "bad file name or number." and it highlights the "Do While EOF(1) = False" section of my code.
what am i doing wrong?
this is the rest of the module:
' A type to store an employee record
Public Type EmployeeRecord
lastName As String
firstName As String
age As Integer
sexMale As Boolean
Dim empList() As EmployeeRecord ' the employee list
Dim numEmployees As Integer ' number of employees in the list
'Dim cdlNewEmployee As CommonDialog
Public Function GetEmployee(ByVal index As Integer) As EmployeeRecord
GetEmployee = empList(index)
Public Function GetNumEmployees() As Integer
GetNumEmployees = numEmployees
Public Sub ClearEmployeeList()
' Clear the array.
numEmployees = 0
ReDim empList(numEmployees) As EmployeeRecord
Public Sub AddNewEmployee(ByVal ln As String, _
ByVal fn As String, _
ByVal age As Integer, _
ByVal male As Boolean)
' Add a new employee record to the array.
ReDim Preserve empList(numEmployees) As EmployeeRecord
empList(numEmployees).lastName = ln
empList(numEmployees).firstName = fn
empList(numEmployees).age = age
empList(numEmployees).sexMale = male
numEmployees = numEmployees + 1
Public Function GenderCount(ByVal male As Boolean) As Integer
' Count the # of males/females.
Dim i As Integer
GenderCount = 0
For i = 0 To numEmployees - 1
If empList(i).sexMale = male Then
GenderCount = GenderCount + 1
Public Function FormatNames(ByVal lastName As String, ByVal firstName As String) As String
' Format the given last name and first name to
' the format "LASTNAME, firstname".
FormatNames = UCase(lastName) & ", " & firstName
this is the rest of the form:
Private Sub Form_Load()
' Initialize the array.
mnuSave.Enabled = False
Private Sub cmdQuit_Click()
' Terminate the program.
Private Sub cmdMale_Click()
' Count # of males.
Call MsgBox("Number of males: " & modEmployee.GenderCount(True), vbInformation)
Private Sub cmdFemale_Click()
' Count # of females
Call MsgBox("Number of females: " & modEmployee.GenderCount(False), vbInformation)
Private Sub cmdAdd_Click()
' Display a dialog box for adding a new employee
frmEmployee.Show vbModal, Me
If frmEmployee.gValidInfo Then
Call modEmployee.AddNewEmployee(frmEmployee.gLastName, _
mnuSave.Enabled = True
Private Sub cmdClear_Click()
' Clear the array.
Private Sub lstEList_Click()
' An item is selected. Retrieve employee record from list
' display data in text boxes.
Dim emp As EmployeeRecord
emp = modEmployee.GetEmployee(lstEList.ListIndex)
txtAge = emp.age
If emp.sexMale Then
txtSex = "Male"
txtSex = "Female"
Private Sub lstEList_LostFocus()
' Clear the text boxes
txtAge = ""
txtSex = ""
Private Sub UpdateList()
' Populate the information from the array to the list box.
Dim i As Integer, nEmployees As Integer, str As String
nEmployees = modEmployee.GetNumEmployees()
For i = 0 To nEmployees - 1
str = modEmployee.FormatNames(modEmployee.GetEmployee(i).lastName, _
and this is the other form:
Public gValidInfo As Boolean
Public gLastName As String
Public gFirstName As String
Public gAge As Integer
Public gSexMale As Boolean
Private Sub Form_Load()
gValidInfo = False
gLastName = ""
gFirstName = ""
gAge = 0
gSexMale = True
Private Sub cmdCancel_Click()
' Close this dialog box.
Private Sub cmdOK_Click()
' Validate input and populate the information to the form variables.
If txtFirstName = "" Then
Call MsgBox("First name cannot be empty.", vbExclamation)
If txtLastName = "" Then
Call MsgBox("Last name cannot be empty.", vbExclamation)
If txtAge = "" Then
Call MsgBox("Age cannot be empty.", vbExclamation)
gLastName = txtLastName
gFirstName = txtFirstName
gAge = Val(txtAge)
gSexMale = optMale
gValidInfo = True