Solved

Quick Parsing on click event

Posted on 1998-08-05
6
133 Views
Last Modified: 2010-05-03
I want do a quick parsing routine on click event ...  In my app I'm using the Cmdialog to
open a file "test.txt" in a rich textbox.  The file when will look like this when it's open:

P13XW107456  74      15 T                             8877                     1
P10XW107760  74      15 T                             8878                     1
P13XW101530  74      15 T                             8879                     1

I would like the file to look like this after a click event:

P13XW107456  8877                  
P10XW107760  8878                    
P13XW101530  8879

Any suggestions??                      Thanks, rrh187
0
Comment
Question by:rrh187
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 18

Expert Comment

by:deighton
ID: 1467877
Here is how I'd do it without a richtext box - processing files directly

Processing the RTB could be tricky.

Private Sub Command1_Click()

    Dim a  As String
   
    Open "test.txt" For Input As #1
   
    Open "test2.txt" For Output As #2
   
    Line Input #1, a
 
    Do Until EOF(1)
   
               
        Print #2, Left(a, 11) & "   " & Mid(a, 30, 4)
        'you need to get the positioning right on mid e.g 30 along the 4 chars
       
        Line Input #1, a
               
    Loop
   
    Close #2
    Close #1
   
End Sub

0
 
LVL 2

Expert Comment

by:richtsteig
ID: 1467878
Do you want to save your changes back to the file
or just want to have two different ways to display
the information (toggle)?
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1467879
This addresses the other comment:   He is using the LOADFILE method of the RTF box, so he does not need to read from file.


You can do this a couple ways.  here is one:

public sub ParseLikeRRH187Wants(rtf as RichTextBox)
   dim lLine as long
   dim lPos  as long
   dim lTemp as long
   dim lLineStart as long
   dim szLine     as string

   lLine = 1
   lLineStart = 1
   for lPos = 1 to len(rtf.text)
      lTemp = rtf.getlinefromchar(lPos)
      if lTemp > lLine then
         'get the line and fix it up
         lLine = lTemp
         szLine = mid$(rtf.text, lLineStart, lPos - lLineStart)
         szLine = left$(szLine, 11) & " " & mid$(szLine, 56, 4)
         rtf.selstart = lLineStart
         rtf.sellength = lLineStart - lPos
         rtf.Seltext = szline
         lLineStart = lPos
       end if
     next lPos
end sub
         
         
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rrh187
ID: 1467880
25 Bonus to finish, I used deighton's example and it works great, and richsteig has an interesting ideal, I would like do this on the file that is loaded in the Rich TextBox, I'm not using the the Rich TextBox property "loadfile" I'm using the CMDialog to open different files, and when I do a click event I want the file to change. anthonyc I havn't got your soulition to work yet, I'm still kind-of new at this, but if Iget to work I will award you with the points.

                                                 Thanks for all of your help, rrh187
0
 

Author Comment

by:rrh187
ID: 1467881
hey did you guys forget about me???
0
 
LVL 1

Accepted Solution

by:
raider187 earned 120 total points
ID: 1467882
Use the click event to copy and pase the file a open each ver to display them
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question