Click to See Complete Forum and Search --> : Input a file from a Common Dialog Box


Drew
January 29th, 2001, 11:36 PM
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:


option Explicit

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
Unload me

End If
End Sub

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
frmSplash.Show vbModal
prompt = "Enter your Name."
title = "Your Name"
name = InputBox(prompt, title)
'CommonDialog1.ShowOpen
cdlOpenfile.ShowOpen

'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


'Loop
'for ControlArray = 1 to problemNumber
'Load cmdDisplay(ControlArray)
'leftPos = leftPos + buttonWidth + 30
'cmdDisplay(ControlArray).Left = leftPos
'cmdDisplay(ControlArray).Caption = ControlArray
'cmdDisplay(ControlArray).Visible = true
'next ControlArray
'Close 1
'Close 2
End Sub




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?
a. p
b. g
c. m
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?
a. p
b. g
c. m
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?
a. p
b. g
c. m
d. No initial", D,NO INITIAL,"D. NO INITIAL",5