Error When Getting A Substring Of X Characters Out Of A Parent String Of Less Than X Characters?

Feb 23, 2011

Not sure if too many people know this, but the following line will cause an error:

GroupName.Substring(0, 3) = "jt_"

....if the length of GroupName is less than 3 characters. I always thought it would simply return whatever characters in GroupName, but no, it errors. I must be thinking of the old VB6 days.So, I now have to change the code to:

If (GroupName.Length > 2) Then
If (GroupName.Substring(0, 3) = "jt_") Then

Note that the two comparisons need to be on separate lines. If they are on the same line, such as:

If (GroupName.Length > 2) and (GroupName.Substring(0, 3) = "jt_") Then then the code will still fail as the length command is executed at the same time as the substring command- which will cause the error when the GroupName length is less than 3.Just thought that those of us not aware of this should be!

dp.SyntaxHighlighter.ClipboardSwf = '/dp.SyntaxHighlighter/Scripts/clipboard.swf'
dp.SyntaxHighlighter.HighlightAll('9844f9bfb55449e6a786fa62aaadfa20')
dp.SyntaxHighlighter.HighlightAll('f6d554fd98464bdba9159b319e51b381')
dp.SyntaxHighlighter.HighlightAll('93bf4ca63ad8447abdf084d8a9991e15')

View 8 Replies


ADVERTISEMENT

Retrieve All Possible Substring Matches With Characters From A String?

Dec 16, 2009

Basically I want to retrieve all possible substring matches with n characters from a string, Here's my initial code but it only returns 2 matches.[code]...

View 3 Replies

Remove All Special Characters(except - And /) From A String Including All Cr,lf,crlf, Other Illegal Characters?

Sep 13, 2010

i have been trying to remove special characters. i am not able to remove many crlf in middile of the string.

View 3 Replies

Inputting A String Of Keyboard Characters And Outputting The Characters In Reverse?

Aug 3, 2009

I need to create a console program that allows you to enter a string, of which is then outputted in reverse.

Sample:
Input: Diewas
Output: saweiD

Apparently I need to find out about strings and will also need to use a loop.

View 9 Replies

C#-idiomatic Way To Convert A String Of Characters Into A String Of Hexadecimal Characters?

May 3, 2012

I have a string of characters, but I would like to have a string of hexdecimal characters where the hexadecimal characters are converted by turning the original characters into integers and then those integers into hexadecimal characters. How do I do that?

View 3 Replies

Use .SubString To Get The Last 2 Characters, Instead Of The First 2 Character

Sep 22, 2011

wanted how you can get get characters starting from the right most of that string input, not from the left.

View 4 Replies

Regex - .NET: Manipulating TextBox Input: Dash Every 5 Characters And Removing Special Characters?

Dec 21, 2011

Essentially I am trying to replicate the Windows 7 (In-Windows) activation key TextBox form. The Form where it will auto capitalize letters, remove or deny all non alphanumeric characters except dashes every 5 characters that will be auto-input.I assume this can be done with a fairly complicated replacement Regular Expression but I cannot seem to create one to fit the needs.

This is an Example of what I have right now, but it creates an infinite loop as it removes all characters including dashes, than adds a dash, which changes the text and removes the dash again.

[Code]...

View 4 Replies

Replacing Characters In Textbox (including Special Characters)

Aug 5, 2011

I have two textboxes. I type in one of them and the text gets copied in real time into another textbox. There is one catch. I need to replace specific character with something else.

If I enter a quote " in textbox1, it has to be replaced with " in textbox2.

I started with something like the below code, but obviously this does not work (tried different stuff - this is for demonstration only). In the example below 'a' represents " , and 'b' represents "

Private Sub TextBox1_KeyUp(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.KeyUp
TextBox2.Text = TextBox1.Text

[Code]....

View 2 Replies

Shape Of Really Large Characters Such As Numbers And Alphabetic Characters

May 9, 2011

With the shape of really large characters such as numbers and alphabetic characters + others, is there a way to get that shape as a REGION please?Imagine a really fat snake forming the letter S or two rectangles placed together to form a large letter L or a T like the shapes in TETRIS.

1) Does anyone know of anything in VB.Net that can translate such shapes into a System. Drawing.Region or know of a project elsewhere that achieves this please?

2) While I'm on the subject, how would you SCALE UP / DOWN a System.Drawing.Region please? How would you work out the Transform Matrix required please?

View 1 Replies

VB Mixing Characters When Change Position Of Two Characters In Word

Aug 27, 2011

I'm making an application that will change position of two characters in Word.

[Code]...

Program works good, it is mixing characters good, but it doesn't write text to the file. It will write text in console, but not in file. Note: Program is working only with words that are divisible by 2, but it's not a problem. Also, it does not return any error message.

View 1 Replies

VS 2010 Turn Only Selected Characters Into Password Characters

Feb 20, 2011

I'm making a custom control suited for handling passwords. I have created a control that inherits from a text box and I have implemented a lot of things so far. But what i want to do now is create a system so that when a user types It will display his last character typed for a X amount of time. Is there a way to turn only selected characters into password characters and still be able to get the password text from the Text property ?

View 4 Replies

Make A .SubString Get The Characters From Right To Left Not Left To Right?

Oct 8, 2011

I am trying to figure out how to make a .SubString get the characters from right to left not left to right.Say if a user enters 123456789 in text box 1 and I use textbox1.text.SubString(0,2) it will display 12. But, I want it to get 89.I do not want it to get 98, but 89. I tried textbox.text.substring (0, -2) but that just gives an error.So if Gold is entered it gets ld

Fun
it gets un
VisualBasic
it gets ic

View 5 Replies

Add Characters Between Characters In A Line Of Text?

Aug 4, 2009

I know that the topic is kind of weird, but I will explain that here. I am reading text from a text box and inserting that into a listbox. I am wanting to read what the user inputs into the text box and add a character between each character they type. Here is what im wanting to do written out[code]...

View 4 Replies

No Special Characters | Minimum Characters

Aug 4, 2010

example. i have 2 textboxes and if there empty it says "Incorrect Information", but how do i make it that like when a person enters something into the textbox1 it can be 3 values minimum.. like it could be eather 2 letters 1 number or what ever just more than 3 values (no special characters), and on the password.. 6 values minimum (no special characters).

[Code]...

View 14 Replies

Asp.net - Character Support - Translate Higher ASCII Characters To Lower ASCII Characters?

Aug 7, 2009

So I have an ASP.Net (vb.net) application. It has a textbox and the user is pasting text from Microsoft Word into it. So things like the long dash (charcode 150) are coming through as input. Other examples would be the smart quotes or accented characters. In my app I'm encoding them in xml and passing that to the database as an xml parameter to a sql stored procedure. It gets inserted in the database just as the user entered it.

The problem is the app that reads this data doesn't like these characters. So I need to translate them into the lower ascii (7bit I think) character set. How do I do that? How do I determine what encoding they are in so I can do something like the following. And would just requesting the ASCII equivalent translate them intelligently or do I have to write some code for that?

Also maybe it might be easier to solve this problem in the web page to begin with. When you copy the selection of characters from Word it puts several formats in the clipboard. The straight text one is the one I want. Is there a way to have the html textbox get that text when the user pastes into it? Do I have to set the encoding of the web page somehow?

[Code]...

View 4 Replies

Add 1 To First 3 Characters Of A String?

Nov 14, 2011

I have a barcode that once scanned returns a string 8 characters long.

Further along the program I have this line of [code]...

View 1 Replies

Get First X Characters Of A String?

Mar 14, 2009

I want to be able to get the first x characters of a string

View 2 Replies

.net - Rearrange Characters In A String?

Jun 27, 2011

I have a string like this:

1a2b3c4d5e6f7g8h

And I need to rearrange it as follow:

a1b2c3d4e5f6g7h8

Do you understand what I mean? For each two characters, the numerical character swapping place with the following letter, i.e. from 1a change it to a1.how to rearrange the numerical characters and letters in the string? My string always has the said pattern, i.e. one integer then followed by a letter then followed by a integer then followed by a letter and so on.

View 2 Replies

Add Space After Every 4 Characters To String?

Nov 19, 2011

How can I add space after every 4 characters to string that returned from a function? I know the returned value it is 8 or 12 or ...etc.

for example function myString will return the value of ABCDEF12XY1Z

How can i display in textbox1 as ABCD EF12 XY1Z

View 7 Replies

Adding Characters To A String

Apr 2, 2010

I have a string value (which is a hex value) that is displayed as so...F8 30 00 3D FC 13 F8 30 00 01 31 73 34 FE 34 DE F8 30 00 3D FC 13 F8 30 00 01 31 73 34 FE 34 DE F8 30 00 3D FC 13 F8 30 00 01 31 73 34 FE 34 DEThis continues on in this exact pattern. What I am trying to do is to get a " " inserted after the first 24 characters, and then after the next 24, delete a character and place an Enter or Return value. Then I would like another " " after the next 24, and then after 24 more, delete a character and place an Enter or Return value so on until the end of the string. The format would then look like this.[code]I know this is probably done with some type of array and loop, but I'm not even sure where to get started.

View 8 Replies

Asp.net - Fix Special Characters In String?

Aug 3, 2010

I've got a program that in a nutshell reads values from a SQL database and writes them to a tab-delimited text file.The issue is that some of the values in the database have special characters (TM, dash, ellipsis, etc.) When written to the text file, the formatting is lost and they come across as junk "â„¢ or â€" etc"

When the value is viewed in the immediate window, before it is written to the txt file, everything looks fine. My guess is that this is an issue of encoding. But, I'm not real sure how to proceed, where to look, or what to look for.Is this ASCII or UTF-8? If it's one of those how do I correct it before it's written to the text file.Here's how I build the text file (where feedStr is a StringBuilder)

objReader = New StreamWriter(filePath)
objReader.Write(feedStr)
objReader.Close()

View 1 Replies

Changing Characters In A String?

Mar 4, 2009

character manipulation in a String.

How do you change characters in a particular string and set them to a particular value.

For eg. I want to change the third character of the string "hello" to Y = > i get "heYlo".

I tried using the Chars function but it says that the function is read only.

View 4 Replies

Check For Certain Characters In A String?

May 17, 2011

I am just a beginner in VB programming. What if I want to check if a certain subtext is present in a string? For example, what do I code if I want to check if the word "hello" is present in a particular string or not?

View 3 Replies

Copy Certain Characters From A String?

Sep 22, 2010

I am in a rather silly situation...suppose I have a text box in which I enter a line of text/characters/numbers...how would I be able to display the last two or first two (or may be middle two?) characters into another text box.

Example: I write "Hello World!" in the first text box and the program should display the first two characters from that text box, i.e. "he".

View 5 Replies

Counting Characters In A String?

Feb 4, 2011

Ok, so I have a string called item. It's value is "Coffe`". When I try to get the number of caractors by using:

textcount = item.length

However it returns with the value "5". even though there is 6 caracters.

View 6 Replies

Find Some Characters In A String?

Sep 16, 2008

I need to return everything between the 2 dashes:

"xxx-12345-xxx"

Here's my conditions:

Sometimes the middle part may contain more than 5 characters, so it could look like this: "xxx-12345AB-xxx" Sometimes there's no second dash, so a string could look like this: "xxx-12345"

View 13 Replies

Finding Characters In A String?

Mar 28, 2011

how I would find certain characters in a string.

View 4 Replies

Get Number Of Characters In A String?

Jan 30, 2010

I have a query to solve for which I have coded. But my code produces output only for those hardcoded values found in the text file. I have a text file which is given as the input to my code. The text file contains lines with "_DIA" , "_DIA_some number" etc. In this case I need to remove few letters from that field.

Eg: 1)if the name field contains 1234567_DIA_2.PRT, I need to remove "_DIA_2" from the name field and concatenate the .PRT with the number. 2)if the name field contains 1234567_DIA1.PRT, then remove "_DIA1" and concatenate. I need to store the number of characters removed and add so many number of blank spaces with the name field after the concatenation.

for the 1) case I need to concatenate and add 6 spaces with the name field. for the 2) case I need to concatenate and add 5 spaces with the name field.

I'm not sure how to find the number of characters from "_" to ".", underscore need to be considered in the counting and the dot(.) should not be taken into account.

View 2 Replies

Get String Items Around A Set Of Characters?

Oct 18, 2011

Ok I am on the last part of this part of my project... If I have a strings like[code]...

I am having to parse address information out of a file... The parser works fine for addresses that do not contain a CR which means County Road. So I am thinking I can strip the address part out of the string I am passing into the parser by using something like.[code]...

View 1 Replies

Get The Leftmost Characters From A String?

Jun 21, 2010

I want to just get the leftmost characters from a string. Something that should be very simple...and yet!

Here is an example:

Code:
Dim strA As String = Now.ToString
strA = Strings.Left(strA, Len(strA - 1))

Why does this return an error: "Conversion from string to double is not valid."

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved