Solved

Quick Parsing on click event

Posted on 1998-08-05
6
129 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
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now