|
-
Mar 22nd, 2006, 06:13 AM
#1
Thread Starter
Junior Member
Read from properties file
Hi,
I have a property file names sourcesheetproperties.txt where i have the text as
path=vvvvv
Level=111
I want to retrieve the values from the text files as passing property name such as "path" and "Level". I tried to use propertybag class but however was giving errors while using .contents property.
Is anybody aware of freeware dll or vbcode which i can use?
Thanks in advance.
Regards,
Sharmili.
-
Mar 22nd, 2006, 06:56 AM
#2
Frenzied Member
Re: Read from properties file
Is this an arbitrary properties file (ie bespoke content, and format) ?
"As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein
It's turtles! And it's all the way down
-
Mar 22nd, 2006, 07:01 AM
#3
Thread Starter
Junior Member
Re: Read from properties file
Thanks your reply.
It will be in fixed format. i.e name=value where name and value both are strings.
-
Mar 22nd, 2006, 07:04 AM
#4
Frenzied Member
Re: Read from properties file
"As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein
It's turtles! And it's all the way down
-
Mar 22nd, 2006, 07:26 AM
#5
Thread Starter
Junior Member
Re: Read from properties file
We manually create the properties file.
-
Mar 22nd, 2006, 07:34 AM
#6
Re: Read from properties file
VB Code:
Private Sub Form_Load()
Dim filename As String
Dim lPos As Long
cdlg1.ShowOpen
filename = cdlg1.filename
Open filename For Input As #1
Do Until EOF(1)
Line Input #1, strdata
lPos = InStr(strdata, "<")
Do While lPos
lEnd = InStr(lPos, strdata, ">")
Text1.Text = Text1.Text + Mid$(strdata, lPos + 1, lEnd - lPos - 1) & vbCrLf
lPos = InStr(lEnd, strdata, "<")
lEnd = InStr(lPos, strdata, ">")
Text2.Text = Text2.Text + Mid$(strdata, lPos + 1, lEnd - lPos - 1) & vbCrLf
lPos = InStr(lEnd, strdata, "<")
Loop
Loop
Close #1
End Sub
format your properties file in the format
<path><vvvvv>
<Level><111>
this is because its easier to parse the values .now add two textboxes with multiline = true and scrollbars =2
and add a common dialog control cdlg1
__________________
________________0îîî___
___îîî0________(___)____
__(___)_________) _/_____
___\_ (_________(_/______
____\_)_________________
-
Mar 22nd, 2006, 07:43 AM
#7
Thread Starter
Junior Member
Re: Read from properties file
Thank you once again for your speedy reply.
I want to hv a generic class with methods such as getProperty(name) and setProperty(name) which will easy for me.
The functionality should be similar to propertybag class.
-
Mar 22nd, 2006, 08:04 AM
#8
Re: Read from properties file
 Originally Posted by sharmili
Thank you once again for your speedy reply.
I want to hv a generic class with methods such as getProperty(name) and setProperty(name) which will easy for me.
The functionality should be similar to propertybag class.
thanks bushmob for that ,he taught me parsing values !!
the reason why i used < and > is to make it easier for the code to parse the values .to write values to file in this format should not be difficult i guess .
how do u create classes in vb ?? i am not aware of classes in vb!!
__________________
________________0îîî___
___îîî0________(___)____
__(___)_________) _/_____
___\_ (_________(_/______
____\_)_________________
-
Mar 22nd, 2006, 08:06 AM
#9
Re: Read from properties file
 Originally Posted by litlewiki
how do u create classes in vb ?? i am not aware of classes in vb!!
Project/Add Class Module
-
Mar 22nd, 2006, 08:18 AM
#10
Re: Read from properties file
okay class modules thought something else!!
__________________
________________0îîî___
___îîî0________(___)____
__(___)_________) _/_____
___\_ (_________(_/______
____\_)_________________
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|