Link to home
Start Free TrialLog in
Avatar of aneilg
aneilgFlag for United Kingdom of Great Britain and Northern Ireland

asked on

vb right function

I am referencing the following file. But i need to make it more dynamic.
The file name will change each time except for the last 6 characters of the file FREDDY. But I will also need to exclude the .dat section.

If I do something like

Dim Process_Claims_File – righttrim

load_success=Process_Claims_File ("\\server\Renewal_Date_Capture\RDCDATA000001FREDDY.dat", myClaims_Journal)
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

aneilg,

Please elaborate on what you are trying to do.

Patrick
Avatar of Bill Prew
Bill Prew

Not sure what your question is?

Are you trying to figure out how to locate the "new" file, based on looking for just FREDDY?

Or are you asking how to extract the FREDDY from the file name that will change each day?

~bp
can you please clarify the issue?
do you need the 00001 part "set" into the string, or extracted from the string?
aka where does which value come from?

if you want to "set" the value, you might do something like this:

dim strFile 
strFile = "\\server\Renewal_Date_Capture\RDCDATA$$$$$$FREDDY.dat"
strFile = replace(strFile, "$$$$$$", right( "000000" & your_number , 6 )) 
load_success=Process_Claims_File (strFile, myClaims_Journal) 

Open in new window


hope this helps
Sorry, I dont really understand the question, can you try again?

In general, the Right function will return the rightmost characters of a string.  eg wscript.echo  Right("ThisIsAnExample",3)  will produce "ple"

The Left function will do similar on the leftmost characters.  eg wscript.echo  Left("ThisIsAnExample",3) will produce "Thi"

Perhaps you want the leftmost characters excluding the rightmost 6 (for FREDDY) and 4 (for .dat)?

If so, Left(strYourVarilable,Len(strYourVariable)-10) should produce that.

Still not sure what you are going to do with that though?
Avatar of aneilg

ASKER

hello sorry.
i just need to Identify the file name from freddy.
the location will always be the same.

so if the file is ("\\server\Renewal_Date_Capture\RDCDATA000001FREDDY.dat", myClaims_Journal)
i know i nedd to process file freddy.

or if the file is ("\\server\Renewal_Date_Capture\RDCDATA000001abcdef.dat", myClaims_Journal)
i know i nedd to process file abcdef.
How about this:

strFile = "\\server\Renewal_Date_Capture\RDCDATA000001abcdef.dat"
strPiece = Right(Left(strFile, Len(strFile)-4), 6)

Open in new window

~bp
Avatar of aneilg

ASKER

thanks.
Avatar of aneilg

ASKER

sorry guys my mistake.

basically what i want to do is read a file from a path.
 ("\\server\Renewal_Date_Capture\RDCDATA000001FREDDY.dat", myClaims_Journal)

i want to take out RDCDATA000001FREDDY.dat and use that file name.
So, are you saying that there is a file in a folder that you want to use and that it has a name that you don't know but it will end in FREDDY.dat?
Avatar of aneilg

ASKER

Sorry for the confusion guys.

What I want to do is just get the .dat file name, irrespective of what the file is called.
I want to get the name of the .dat file from the folder.
Avatar of aneilg

ASKER

on my folder, the faile name can be anything.
("\\server\Renewal_Date_Capture\RDCDATA000001FREDDY.dat", myClaims_Journal)

or
("\\server\Renewal_Date_Capture\RDCDATA000001PAUL.dat", myClaims_Journal)

i need to get the .dat file name.
Okay, we are getting somewhere.

Is the path and partial filename always the same?

Path is always \\server\Renewal_Date_Capture?
File name always starts with RDCDATA000001?
File name always ends with .dat?

Will there be many files in this folder when the script runs or just one?
Avatar of aneilg

ASKER

thanks for your help alan.

the folder will always be the same.
the file will NOT start with RDCDATA000001.
the file will always end in .dat.

so i need the name of the full .dat file to use.
And there will only be one .dat file in the folder when you run the script?
ASKER CERTIFIED SOLUTION
Avatar of Alan_White
Alan_White
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aneilg

ASKER

thanks alan.

really do Appreciate your help.
Avatar of aneilg

ASKER

fandabidozi