Welcome to Dream.In.Code
Become a VB Expert!

Join 137,228 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,893 people online right now. Registration is fast and FREE... Join Now!




Using Common Dialogue

2 Pages V  1 2 >  
Reply to this topicStart new topic

Using Common Dialogue, I need help

pau-pau
30 Jan, 2007 - 01:48 AM
Post #1

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 24


My Contributions
CODE

Private Sub Form_Activate()
cdlCommon.Flags = cdlOFNHideReadOnly ' Hides read only files
cdlCommon.Filter = "All Files (*.*)|*.*|Text Files" & _
"(*.txt)|*.txt|"

' Specify default filter
cdlCommon.FilterIndex = 2
cdlCommon.ShowOpen
End Sub


i am making a MLFQ scheduling algorithm using VB and i need to to open a file using common dialogue then display my data in a datagrid.
i have this code but i can only make it work when the form initially runs, I need the common dialogue to work when i press a command button.

can someone help me please
User is offlineProfile CardPM
+Quote Post

KeyWiz
RE: Using Common Dialogue
31 Jan, 2007 - 08:11 AM
Post #2

D.I.C Regular
Group Icon

Joined: 26 Oct, 2006
Posts: 428


Dream Kudos: 125
My Contributions
Move the code that works to it's own sub routine and call it from the start and from the button_Click method.
User is offlineProfile CardPM
+Quote Post

pau-pau
RE: Using Common Dialogue
5 Feb, 2007 - 03:17 AM
Post #3

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 24


My Contributions
i haven't been able make my scheduling lately,

need to balance my time with other works

i've worked out the code for openning the file using the common dialogue

now im just learning how to use a text file as an input for my cpu scheduling algorithm, and use delimiters and datagrids to display my input

can someone help???

User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Using Common Dialogue
6 Feb, 2007 - 08:31 AM
Post #4

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,914



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
Are you familiar with the Inbuilt VB File Handling Statements or the FileSystemObject?
User is offlineProfile CardPM
+Quote Post

pau-pau
RE: Using Common Dialogue
7 Feb, 2007 - 03:35 AM
Post #5

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 24


My Contributions
nope,

I'm just a newbie when it comes to VB,

right now i'm looking for tutorials and sample programs to help me make my code,

can you tell me how that works
User is offlineProfile CardPM
+Quote Post

Louisda16th
RE: Using Common Dialogue
7 Feb, 2007 - 03:43 AM
Post #6

 
Group Icon

Joined: 3 Aug, 2006
Posts: 1,790



Thanked: 1 times
Dream Kudos: 755
My Contributions
Click Here
User is offlineProfile CardPM
+Quote Post

pau-pau
RE: Using Common Dialogue
7 Feb, 2007 - 04:01 AM
Post #7

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 24


My Contributions
thanks,
I have found and tried a code for FIleSystemObjects,

and now I'm trying to use it for my input, which is a text file and have a pattern of:
<job id> <arrival time> <memory Size> <jobtype> <CPUBurst>

each one is a numerical value and i need to place it in my datagrid(im using flexgrid) the job id determines my number of rows...

i'm open for help and suggestions^_^
User is offlineProfile CardPM
+Quote Post

Louisda16th
RE: Using Common Dialogue
7 Feb, 2007 - 04:10 AM
Post #8

 
Group Icon

Joined: 3 Aug, 2006
Posts: 1,790



Thanked: 1 times
Dream Kudos: 755
My Contributions
If you're trying to figure out how to extract each field, then try this:
Place each piece of data within quotes (or any other symbol you like). When you are reading from a text file, store the entire data in a string variable. Next read the string character by character. When you see a quote you'll know whether its the beginning or end of a field.
Hope it helps smile.gif
User is offlineProfile CardPM
+Quote Post

pau-pau
RE: Using Common Dialogue
7 Feb, 2007 - 04:16 AM
Post #9

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 24


My Contributions
thanks,

I've got an idea on what to do,

will i be using born2c0de's code to read the text file:

CODE

dim str as string
Open "filename" for input as #1
While Not Eof(1)
   line input #1 , str
wend
close #1



User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Using Common Dialogue
7 Feb, 2007 - 04:26 AM
Post #10

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,914



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
Yes, you can use that loop.
Once you extract each line, you can use this Function to extract a particular word as long as the separator field is specified ie. the " " space.
CODE

Public Function ExtractWordBySep(source As String, count As Integer, sep As String) As String
    Dim res As String
    Dim i As Integer, pos As Integer, ct As Integer
    res = ""
    pos = 1
    ct = 1
    For i = 1 To Len(source)
        If ct = count Then Exit For
        If Mid(source, i, 1) = sep Then ct = ct + 1: pos = i + 1
    Next i
    If (count > ct) Or count = 0 Then ExtractWordBySep = "": Exit Function
    
    For i = pos To Len(source)
        If Mid(source, i, 1) <> sep Then
            res = res + Mid(source, i, 1)
        Else
            Exit For
        End If
    Next i
    ExtractWordBySep = res
End Function


So if your line (stored in str) contains This is Line One
Using ExtractWordBySep(str,3," ") will return Line
User is offlineProfile CardPM
+Quote Post

pau-pau
RE: Using Common Dialogue
7 Feb, 2007 - 04:48 AM
Post #11

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 24


My Contributions
thanks alot

I'll study your variables and code right away,


User is offlineProfile CardPM
+Quote Post

pau-pau
RE: Using Common Dialogue
7 Feb, 2007 - 05:12 AM
Post #12

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 24


My Contributions
i cant seem to figure out the variable "Len" and "Mid"
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:04PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month