Results 1 to 10 of 10

Thread: Read from properties file

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    21

    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.

  2. #2
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    21

    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.

  4. #4
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Read from properties file

    What generated the 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

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    21

    Re: Read from properties file

    We manually create the properties file.

  6. #6
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    Re: Read from properties file

    VB Code:
    1. Private Sub Form_Load()
    2. Dim filename As String
    3. Dim lPos As Long
    4. cdlg1.ShowOpen
    5.  
    6. filename = cdlg1.filename
    7.  
    8. Open filename For Input As #1
    9.     Do Until EOF(1)
    10.         Line Input #1, strdata
    11.         lPos = InStr(strdata, "<")
    12.         Do While lPos
    13.             lEnd = InStr(lPos, strdata, ">")
    14.             Text1.Text = Text1.Text + Mid$(strdata, lPos + 1, lEnd - lPos - 1) & vbCrLf
    15.             lPos = InStr(lEnd, strdata, "<")
    16.             lEnd = InStr(lPos, strdata, ">")
    17.             Text2.Text = Text2.Text + Mid$(strdata, lPos + 1, lEnd - lPos - 1) & vbCrLf
    18.             lPos = InStr(lEnd, strdata, "<")
    19.         Loop
    20.     Loop
    21. Close #1
    22. 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________(___)____
    __(___)_________) _/_____
    ___\_ (_________(_/______
    ____\_)_________________

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    21

    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.

  8. #8
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    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!!
    __________________
    ________________0îîî___
    ___îîî0________(___)____
    __(___)_________) _/_____
    ___\_ (_________(_/______
    ____\_)_________________

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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

  10. #10
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    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
  •  



Click Here to Expand Forum to Full Width