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.
Re: Read from properties file
Is this an arbitrary properties file (ie bespoke content, and format) ?
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.
Re: Read from properties file
Re: Read from properties file
We manually create the properties file.
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
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.
Re: Read from properties file
Quote:
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!!
Re: Read from properties file
Quote:
Originally Posted by litlewiki
how do u create classes in vb ?? i am not aware of classes in vb!!
Project/Add Class Module
Re: Read from properties file
okay class modules thought something else!!