473,385 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Get a specific letter from a word

How do you get a specific letter from a word?

For example, in English, I would say:

Get the fifth letter from the word "Computer"

Then the letter 'u' will be returned. (C-O-M-P-U-..., 'u' is the fifth letter)
How do you 'translate' this sentence into VB.net? Thanks!
--
Xero

http://www.chezjeff.net
My personal web portal
Nov 21 '05 #1
5 3847
Use the Chars indexer property of the string:

Dim s As String = "Computer"
Console.WriteLine (s.Chars(4)) 'Index is zero based

HTH

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> wrote in message
news:FC**********************************@microsof t.com...
How do you get a specific letter from a word?

For example, in English, I would say:

Get the fifth letter from the word "Computer"

Then the letter 'u' will be returned. (C-O-M-P-U-..., 'u' is the fifth
letter)
How do you 'translate' this sentence into VB.net? Thanks!
--
Xero

http://www.chezjeff.net
My personal web portal
Nov 21 '05 #2
Hi Jeff

this is one possible way

Dim strWoord As String = "COMPUTER"
Dim strLetter As String
Dim intLetter As Integer
strLetter = InputBox("Give the ... letter")
If strLetter.Length > 0 AndAlso IsNumeric(strLetter) Then
intLetter = CInt(strLetter)
If intLetter > strWoord.Length Then
MsgBox("The word isn't this long")
Else
MsgBox("The letter is " & Mid(strWoord, intLetter, 1))
End If
End If

hth

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> wrote in message
news:FC**********************************@microsof t.com...
How do you get a specific letter from a word?

For example, in English, I would say:

Get the fifth letter from the word "Computer"

Then the letter 'u' will be returned. (C-O-M-P-U-..., 'u' is the fifth letter) How do you 'translate' this sentence into VB.net? Thanks!
--
Xero

http://www.chezjeff.net
My personal web portal

Nov 21 '05 #3
Nice! I've been using Mid() but that looks better.

Matthew

"Shiva" <sh******@online.excite.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Use the Chars indexer property of the string:

Dim s As String = "Computer"
Console.WriteLine (s.Chars(4)) 'Index is zero based

HTH

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> wrote in
message
news:FC**********************************@microsof t.com...
How do you get a specific letter from a word?

For example, in English, I would say:

Get the fifth letter from the word "Computer"

Then the letter 'u' will be returned. (C-O-M-P-U-..., 'u' is the fifth
letter)
How do you 'translate' this sentence into VB.net? Thanks!
--
Xero

http://www.chezjeff.net
My personal web portal

Nov 21 '05 #4
Xero schrieb:
How do you get a specific letter from a word?

For example, in English, I would say:

Get the fifth letter from the word "Computer"

Then the letter 'u' will be returned. (C-O-M-P-U-..., 'u' is the fifth letter)
How do you 'translate' this sentence into VB.net? Thanks!


Take a look at the documentation:

'GetChar' gets a single character from a string. 'Mid' can be used to
get more than one character.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #5
Jeff,

I miss the one I use

dim MyFiftLetter as String = "Computer".substring(4,1)

I hope this makes it more complete

Cor

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )>
How do you get a specific letter from a word?

For example, in English, I would say:

Get the fifth letter from the word "Computer"

Then the letter 'u' will be returned. (C-O-M-P-U-..., 'u' is the fifth
letter)
How do you 'translate' this sentence into VB.net? Thanks!
--
Xero

http://www.chezjeff.net
My personal web portal

Nov 21 '05 #6

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

Similar topics

5
by: Andrew James | last post by:
Gentlemen, I'm running into a problem whilst testing the parsing of a language I've created with TPG . It seems that for some reason, TPG balks when I try to parse an expression whose first...
1
by: peteyjr | last post by:
Hi I have a asp.net page with a database connection where I need to export adresses into a MS Word Serial Letter. Is this possible and if how?? Any help is well appreciated Peter
1
by: DP | last post by:
hi, i know how to open ms word in access, but is there a way to open a specific file?? i've a created a mail merge letter, and i want to be able to click on a button in access, and it opens...
2
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to...
12
by: Dixie | last post by:
Is there a way to shell to Microsoft Word from Access and load a specific template - using VBA? dixie
75
by: ume$h | last post by:
/* I wrote the following program to calculate no. of 'a' in the file c:/1.txt but it fails to give appropriate result. What is wrong with it? */ #include"stdio.h" int main(void) { FILE *f;...
5
by: VMI | last post by:
How can I call the Microsoft Word Letter Wizard from within a C# Windows application? And once I open the Letter Wizard from the application, can I automatically paste text on one of the fields...
9
by: Ulterior | last post by:
Hi, everyone, I have a simple problem, which bothers me for some while. I will try to explain it - There is some string, whith different letters in it. Is it possible to analyse this string...
4
by: zcabeli | last post by:
Hi all, i'm currently struggling to perform the above mentioned replacement. i already know how to catch the first letter in each word and determined if it's regular or capital. however, i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.