[RESOLVED] How do I use CommonDialog???
Do I need to do something before I can use CommonDialog in my code.
The below code doesn't work for me ... Error at CommonDialog :confused:
VB Code:
Private Sub MenuFile_Click(Index As Integer)
Select Case Index
Case 0 'Open
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Dim tmp() As String
Dim Lines() As String
Lines = Split(Input(LOF(1), 1), vbCrLf)
Close #1
'now you have each line in its own array element
For x = 0 To UBound(Lines)
tmp = Split(Replace(Lines(x), "//", ""), "/") 'This lines removes the // and then splits by /
'so now you have an array for the first line which is as follows
'tmp(0) = "Header1"
'tmp(1) = "info"
'tmp(2) = "moreinfo"
'tmp(3) = "yet some more"
'do what you need to
Next
Case ...
Re: How do I use CommonDialog???
You may (at least) need to set Flags, Filter and assign file name to a string variable:
VB Code:
Private Sub Command2_Click()
Dim strFile As String
With CommonDialog1
.Flags = cdlOFNExplorer Or cdlOFNHideReadOnly
.Filter = "Text (*.txt)|*.txt"
.ShowOpen
strFile = .FileName
If Not strFile = "" Then
Open strFile For Input As #1
'do something
Close #1
End If
End With
End Sub
Re: How do I use CommonDialog???
You have to select it from the components list. Here is a quick sample of it use.
http://vbforums.com/attachment.php?attachmentid=39609
Re: How do I use CommonDialog???
Ahh ..., David you're right - I thought of something completely different ...
Re: How do I use CommonDialog???
[RESOLVED] How do I use CommonDialog???
Thanks guys!
Got it working :)
1 Attachment(s)
Re: [RESOLVED] How do I use CommonDialog???
This little app will show you all the functions of CommonDialog. It uses a RichTextBox to show the difference between loading a txt and rtf file. :)