CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 31

Thread: ABOUT STRING READING FROM textfile

Threaded View

  1. #1
    Join Date
    Feb 2010
    Posts
    11

    ABOUT STRING READING FROM textfile

    Hello,
    I got a text file with that kind of data

    ALARM= ALARM1
    ZONE= ZONE6
    DESCRIPTION= NEED TO REPLACE

    ALARM= ALARM5
    ZONE= ZONE5
    DESCRIPTION= OK FOR 2 YEAR

    ALARM= ALARM9
    ZONE= ZONE7
    DESCRIPTION= NEED MAINTANENCE


    When textfile contain "ALARM=" i can load alarm name to listbox with the code below and display
    ALARM1
    ALARM5
    ALARM9 on the listbox

    '+++++++++++++++++++++++++

    Private Sub Command1_Click()
    nFileNum = FreeFile
    Open "C:\3.txt" For Input As nFileNum
    lLineCount = 1
    Do While Not EOF(nFileNum)
    Line Input #nFileNum, sNextLine
    sNextLine = sNextLine & vbCrLf
    sText = sNextLine

    If InStr(sText, "ALARM=") = 1 Then

    List1.AddItem (Mid(sText, 7, (Len(sText) - 7)))

    End If

    Loop

    Close nFileNum

    End Sub

    '++++++++++++++++++

    What i want now is this function

    Private Sub List1_Click()
    text1.text= ?????????
    End Sub

    I mean ,when i click ALARM1 on list item i want to display
    ALARM= ALARM1
    ZONE= ZONE6
    DESCRIPTION= NEED TO REPLACE


    When i click ALARM9 on list item i want to display
    ALARM= ALARM9
    ZONE= ZONE7
    DESCRIPTION= NEED MAINTANENCE

    And so on, there is one space line between these group.

    I have attach my sample project. That will be great if anyone can find the solution.

    Many thanks
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)