473,748 Members | 8,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stripping letters from filename

Hey all,
I have a file name like Eng-Cat-01-01-01.txt. I need to do a loop that
starts stripping the letters from the front of this file name (which
I'll store as a variable) until it reaches the "Cat" part. So I would
have a variable "Cat-01-01-01.txt" that I can use to build up another
string.

Trouble is, I'm lost. Can't figure out how to do this in VB.net. Could
anyone point me in the right direction?

MANY thanks!

cm
Jul 18 '07 #1
7 1387
You should probably convert the strings to all upper or all lower case, but
this is the idea.

Dim fn As String = "Eng-Cat-01-01-01.txt"
Console.Out.Wri teLine(fn.Subst ring(fn.IndexOf ("Cat")))
"Benway" wrote:
Hey all,
I have a file name like Eng-Cat-01-01-01.txt. I need to do a loop that
starts stripping the letters from the front of this file name (which
I'll store as a variable) until it reaches the "Cat" part. So I would
have a variable "Cat-01-01-01.txt" that I can use to build up another
string.

Trouble is, I'm lost. Can't figure out how to do this in VB.net. Could
anyone point me in the right direction?

MANY thanks!

cm
Jul 18 '07 #2
Benway wrote:
I have a file name like Eng-Cat-01-01-01.txt. I need to do a loop
that starts stripping the letters from the front of this file name
(which I'll store as a variable) until it reaches the "Cat" part. So I
would have a variable "Cat-01-01-01.txt" that I can use to build up
another string.
Dim sFilename As String _
= "Eng-Cat-01-01-01.txt"
Dim iPos as Integer _
= sFilename.Index of( "Cat" )

If iPos -1 Then
? sFilename.SubSt ring( 0, iPos )
? sFilename.SubSt ring( iPos + "Cat".Lengt h() + 1 )

' or thereabouts ...

HTH,
Phill W.
Jul 18 '07 #3
Phill W. wrote:
Benway wrote:
>I have a file name like Eng-Cat-01-01-01.txt. I need to do a loop
that starts stripping the letters from the front of this file name
(which I'll store as a variable) until it reaches the "Cat" part. So
I would have a variable "Cat-01-01-01.txt" that I can use to build up
another string.

Dim sFilename As String _
= "Eng-Cat-01-01-01.txt"
Dim iPos as Integer _
= sFilename.Index of( "Cat" )

If iPos -1 Then
? sFilename.SubSt ring( 0, iPos )
? sFilename.SubSt ring( iPos + "Cat".Lengt h() + 1 )

' or thereabouts ...

HTH,
Phill W.
Thanks guys!

cm
Jul 18 '07 #4
Benway wrote:
Hey all,
I have a file name like Eng-Cat-01-01-01.txt. I need to do a loop
that starts stripping the letters from the front of this file name
(which I'll store as a variable) until it reaches the "Cat" part. So I
would have a variable "Cat-01-01-01.txt" that I can use to build up
another string.

Trouble is, I'm lost. Can't figure out how to do this in VB.net. Could
anyone point me in the right direction?

MANY thanks!

cm
Hey guys, one more thing you might be able to help with: I've got a
string of text in a label (about 10 or so letters). I need to search it
for "Mit" and replace it with "Cat". Any ideas?

Thanks again!

cm
Jul 19 '07 #5
Benway wrote:
I've got a string of text in a label (about 10 or so letters).
I need to search it for "Mit" and replace it with "Cat".
Any ideas?
So you want to "Replace" one value in a "String" with a different value?

There's a couple of keywords for you to look up ... ;-)

Do you have MSDN installed or do you have access to it on the Web?
Without it, you're going to be /really/ struggling to get to grips with
the Framework and all its classes and methods.

HTH,
Phill W.
Jul 19 '07 #6
Benway wrote:
Hey guys, one more thing you might be able to help with: I've got a
string of text in a label (about 10 or so letters). I need to search
it for "Mit" and replace it with "Cat". Any ideas?
SomeText=Replac e(SomeText, "Mit", "Cat")

Andrew
Jul 19 '07 #7
Phill W. wrote:
Benway wrote:
>I've got a string of text in a label (about 10 or so letters).
I need to search it for "Mit" and replace it with "Cat". Any ideas?

So you want to "Replace" one value in a "String" with a different value?

There's a couple of keywords for you to look up ... ;-)

Do you have MSDN installed or do you have access to it on the Web?
Without it, you're going to be /really/ struggling to get to grips with
the Framework and all its classes and methods.

HTH,
Phill W.
Yeah, thanks for pointing me to Google. I'll check there more
thoroughly in the future.

cm
Jul 20 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4919
by: Ralph Freshour | last post by:
I'm taking text from a textarea object and want to strip out characters other than A-Za-z0-9 before I send the data to MySQL table - is there a function I can use to do this in PHP? Thanks...
15
6046
by: Jeff North | last post by:
Hi, I'm using a control called HTMLArea which allows a person to enter text and converts the format instructions to html tags. Most of my users know nothing about html so this is perfect for my use. http://www.interactivetools.com/products/htmlarea/ This only works with IE5.5+. What I need to do is to take this html formatted text and only display part of the text on a web page (much like a news article which shows only part of the...
7
4870
by: Raj | last post by:
Hi I was hoping someone could suggest a simple way of stripping non-numeric data from a string of numbers. For example, if I have "ADB12458789\n" I would like to remove the letters and the newline from this string. I am new to C so am sure this is simple ut I don't know how to do it! Sorry!
2
13532
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to execute a MailMerge to create mailing labels or customized letters. A label name known to MS Word MailMerge mailing label wizard may be used or a template file containing the field names Line1 thru Line5 for each record to be printed. If a...
7
2288
by: Edward Elliott | last post by:
I'm looking for the "best" way to strip a large set of chars from a filename string (my definition of best usually means succinct and readable). I only want to allow alphanumeric chars, dashes, and periods. This is what I would write in Perl (bless me father, for I have sinned...): $filename =~ tr/\w.-//cd, or equivalently $filename =~ s/// I could just use re.sub like the second example, but that's a bit overkill. I'm trying to...
2
956
by: Greg Larsen | last post by:
I have a string that contains both the filename and the directory. Something like "c:\temp\test.txt". I need a process that will take this string and return only the file portion "text.txt". How might I do this. Kept in mind sometimes the string may contain "C:/temp/test.txt". Any ideas?
0
2294
by: euniceno1 | last post by:
the problem is to count the letters and sequence from a file. the fist thing of my code is to read file and in the main function i create is to count the characters and sequence by using 2 dimension array. where the character include letters and spaces. I am just learning c language at the moment, i have problem with following program: #define TRUE 1 #define FALSE 0 #define MAX_LENGTH 100000 /* Max number of chars read from file */...
2
1782
by: dpreston74 | last post by:
Hello forum. I need to learn how write a SQL script to strip 0s from data and strip alpha letters from alpha numeric data. e.g. I get data like 054, 006, 903, for a dept number. I need to strip the leading zeros from right. and keep the rest of the numbers. Whats the best way to script this striping? Also,
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.