473,805 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3863
Use the Chars indexer property of the string:

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

HTH

"Xero" <jeff_@_chezjef f_._net(remove_ underscores_and _this)> wrote in message
news:FC******** *************** ***********@mic rosoft.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.Lengt h > 0 AndAlso IsNumeric(strLe tter) 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_@_chezjef f_._net(remove_ underscores_and _this)> wrote in message
news:FC******** *************** ***********@mic rosoft.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******@onlin e.excite.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Use the Chars indexer property of the string:

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

HTH

"Xero" <jeff_@_chezjef f_._net(remove_ underscores_and _this)> wrote in
message
news:FC******** *************** ***********@mic rosoft.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".subs tring(4,1)

I hope this makes it more complete

Cor

"Xero" <jeff_@_chezjef f_._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
2645
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 letter is 't' (or, in fact, at any time when 't' is at the beginning of a token). This doesn't happen with any other letter (as far as I know), nor if the 'T' is capitalised. My grammar looks like this:
1
2132
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
1542
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 that specific document. TIA
2
3380
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 confirm that I want to run a query to select the data from the data source file, then it opens the form letter fine. I can preview the merged records and complete a merge to a new document. I have a VB 2006 project (.net framework 2.0) which opens the...
12
10688
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
3560
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; char ch; long int a=0;
5
1739
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 (specifically the Delivery Address field in Recipient Info Tab)? I'm using VS 2005 and MS Word 2002. Thanks.
9
2240
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 and the reffer to it knowing that it has some certain letters in it using only some integer value?
4
5573
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 don't know how to replace this letter with it's corresponding capital letter. perhaps there is an option to change the ascii value of the a character in perl regexp ? for example :
0
10356
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10361
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,...
0
9179
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7644
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
6874
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
5536
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...
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3839
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.