dbTalk Databases Forums  

Remove extraneous text in a text box

comp.databases.ms-access comp.databases.ms-access


Discuss Remove extraneous text in a text box in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
musicloverlch
 
Posts: n/a

Default Remove extraneous text in a text box - 07-25-2011 , 05:00 PM






I get text in a text box that looks like this:

Hello
On computer COMPNAME the following happened:
New File: C:\Folder1\Folder2\LockBox\Usr\ClientName\FileName .xls
7/25/2011 1:25:10 PM

How do I remove everything except the folder path and file name? It's
too much for me.

Reply With Quote
  #2  
Old   
bsn
 
Posts: n/a

Default Re: Remove extraneous text in a text box - 07-25-2011 , 06:24 PM






C:\Folder1\Folder2\LockBox\Usr\ClientName\ = Foldername
FileName.xls = Filename

Bjarne



"musicloverlch" skrev i meddelelsen
news:3b273dd8-e1c7-43e9-84dc-2b9aee46ded6 (AT) e40g2000yqn (DOT) googlegroups.com...

I get text in a text box that looks like this:

Hello
On computer COMPNAME the following happened:
New File: C:\Folder1\Folder2\LockBox\Usr\ClientName\FileName .xls
7/25/2011 1:25:10 PM

How do I remove everything except the folder path and file name? It's
too much for me.

Reply With Quote
  #3  
Old   
bsn
 
Posts: n/a

Default Re: Remove extraneous text in a text box - 07-25-2011 , 07:06 PM



The text must come from some VBA coding...
Checkout VBA module for the form where the text box belongs, and search for
the text...
Correct the VBA code to what u need...(Folder and FileName)
Bjarne


"bsn" skrev i meddelelsen
news:4e2dfb3d$0$56791$edfadb0f (AT) dtext02 (DOT) news.tele.dk...

C:\Folder1\Folder2\LockBox\Usr\ClientName\ = Foldername
FileName.xls = Filename

Bjarne



"musicloverlch" skrev i meddelelsen
news:3b273dd8-e1c7-43e9-84dc-2b9aee46ded6 (AT) e40g2000yqn (DOT) googlegroups.com...

I get text in a text box that looks like this:

Hello
On computer COMPNAME the following happened:
New File: C:\Folder1\Folder2\LockBox\Usr\ClientName\FileName .xls
7/25/2011 1:25:10 PM

How do I remove everything except the folder path and file name? It's
too much for me.

Reply With Quote
  #4  
Old   
Access Developer
 
Posts: n/a

Default Re: Remove extraneous text in a text box - 07-25-2011 , 11:31 PM



"musicloverlch" <lhowey (AT) gmail (DOT) com> wrote

Quote:
I get text in a text box that looks like this:

Hello
On computer COMPNAME the following happened:
New File: C:\Folder1\Folder2\LockBox\Usr\ClientName\FileName .xls
7/25/2011 1:25:10 PM

How do I remove everything except the folder
path and file name? It's too much for me.
What do you mean "I get text in a text box" -- does the Text Box have a
Control Source that binds it to a Field or is it set some other way? Does
the text have line breaks where you show them, or are you just breaking the
lines arbitrarily for usability? If it has line breaks, what is the ASCII
code of the characters make up the line break -- MS Office uses the
character represented by the builtin Constant vbCrLF for which the ASCII is
CHR(10) & CHR(13). Some other definitions of text files only use the
Carriage Return, CHR(10) for a line break.

Assuming there are line breaks, and they are vbCrLf values, then the
following will illustrate how to process the text string to extract the path
and file. The first Function, FeedPAndF, just creates the string for use as
test date by the second Function, ExtrPAndF. Paste these into a standard
Module, then execute from the Immediate Window by typing in ? FeedPAndF().
I've used Debug.Print to print each step so you can follow what it's doing.

Function FeedPAndF() As String

Dim strBuilt As String

strBuilt = "Hello" & vbCrLf & "On computer COMPNAME the following
happened:" & vbCrLf
strBuilt = strBuilt & "New File:
C:\Folder1\Folder2\LockBox\Usr\ClientName\FileName .xls" & vbCrLf
strBuilt = strBuilt & "7/25/2011 1:25:10 PM"

Debug.Print strBuilt

ExtrPAndF (strBuilt)

End Function

Function ExtrPAndF(strInput As String) As String

Dim lngStartPos As Long
Dim lngStopPos As Long
Dim lngLenPAndF As Long
Dim strPathAndFile As String

lngStartPos = InStr(strInput, ":\") - 1
lngStopPos = InStr(lngStartPos, strInput, ".")
lngLenPAndF = lngStopPos - lngStartPos + 4

Debug.Print lngStartPos
Debug.Print Mid(strInput, lngStartPos, 3)
Debug.Print lngStopPos
Debug.Print Mid(strInput, lngStopPos, 4)
Debug.Print lngLenPAndF

strPathAndFile = Mid(strInput, lngStartPos, lngLenPAndF)
Debug.Print strPathAndFile

ExtrPAndF = strPathAndFile

End Function

Once you understand what it's doing, you could combine the parts of the
extracion into one expression, but that would not be as easy to follow,
especially if you have to come back to it after some period of time to
maintain the code. You wouldn't need, or want, the Debug.Print to take
place in production, but it'd be best just to place a single quote ' on the
left of those lines, just in case you need to re-activate them in the
future.

--
Larry Linson, Microsoft Office Access MVP
Co-author: "Microsoft Access Small Business Solutions", published by Wiley
Access newsgroup support is alive and well in USENET
comp.databases.ms-access

Reply With Quote
  #5  
Old   
Patrick Finucane
 
Posts: n/a

Default Re: Remove extraneous text in a text box - 07-26-2011 , 09:23 AM



On Jul 25, 5:00*pm, musicloverlch <lho... (AT) gmail (DOT) com> wrote:
Quote:
I get text in a text box that looks like this:

Hello
On computer COMPNAME the following happened:
New File: C:\Folder1\Folder2\LockBox\Usr\ClientName\FileName .xls
7/25/2011 1:25:10 PM

How do I remove everything except the folder path and file name? *It's
too much for me.
As others noted, there's some code producing the message. The
timedate stamp most likely comes from the function FileDateTime()
Look for FileDateTime or "Hello" or "New File:" in your code modules.
Adjust to suit.

Reply With Quote
  #6  
Old   
musicloverlch
 
Posts: n/a

Default Re: Remove extraneous text in a text box - 07-26-2011 , 11:50 AM



Sorry, this is an ODBC connection to Outlook. I don't contol the
text. I was able to remove the extraneous text using InStr and
Replace functions.

Thanks so much for all your suggestions.


On Jul 26, 9:23*am, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com>
wrote:
Quote:
On Jul 25, 5:00*pm, musicloverlch <lho... (AT) gmail (DOT) com> wrote:

I get text in a text box that looks like this:

Hello
On computer COMPNAME the following happened:
New File: C:\Folder1\Folder2\LockBox\Usr\ClientName\FileName .xls
7/25/2011 1:25:10 PM

How do I remove everything except the folder path and file name? *It's
too much for me.

As others noted, there's some code producing the message. *The
timedate stamp most likely comes from the function FileDateTime()
Look for FileDateTime or "Hello" or "New File:" in your code modules.
Adjust to suit.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.