vb.net help strings

BradleyOng83

Member
Joined
Mar 2, 2006
Messages
19
Programming Experience
Beginner
How to short the word or avoid repeat word e.g the word is "secretsecret'" the program returns only 'secret' as the word.
 
ok...what i mean is the word is "abab" i would like to short the word for compare 1st "a" to third "a" if this is true then make to one "s" only then second word with compare so on. How to write this program?
 
So you want to compare the characters within the string to find out if they are equal? If so just stick a dot after your string variable and you'll find a whole host of functions and subs to manipulate strings.
 
if you want to always check for only double entries like your examples, for example "secretsecret", you could compare the first half of the string to the second half and if they match cut the string in half. for example:

VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sIn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]"secretsecret"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sFirstHalf [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = sIn.Substring(0, Math.Round(sIn.Length / 2))
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sSecondHalf [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = sIn.Substring(Math.Round(sIn.Length / 2))
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] sFirstHalf.Equals(sSecondHalf) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]sIn = sFirstHalf
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE]
 
Back
Top