Solved

Quick Parsing on click event

Posted on 1998-08-05
6
134 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

Technology Partners: 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!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

717 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