Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take a first character from the string

Tags:

Using VB.Net & SQL Server 2005

Dim S as string s = "Rajan" s = "Sajan" 

I want to take a first character from the string (s)

Expected Output

R S 

Need VB.Net Code Help

like image 935
Gopal Avatar asked Oct 06 '11 06:10

Gopal


People also ask

How do you extract the first character of a string?

The idea is to use charAt() method of String class to find the first and last character in a string. The charAt() method accepts a parameter as an index of the character to be returned. The first character in a string is present at index zero and the last character in a string is present at index length of string-1 .

How do you extract the first character of a string in Python?

String Indexing Individual characters in a string can be accessed by specifying the string name followed by a number in square brackets ( [] ). String indexing in Python is zero-based: the first character in the string has index 0 , the next has index 1 , and so on.

How do you get the first character of each word in a string?

To get the first letter of each word in a string: Call the split() method on the string to get an array containing the words in the string. Call the map() method to iterate over the array and return the first letter of each word. Join the array of first letters into a string, using the join() method.

How do you get the first character of a string Java?

To get first character from String in Java, use String. charAt() method. Call charAt() method on the string and pass zero 0 as argument. charAt(0) returns the first character from this string.


1 Answers

Try this..

Dim S As String S = "RAJAN" Dim answer As Char answer = S.Substring(0, 1) 
like image 121
Sam Casil Avatar answered Sep 30 '22 20:09

Sam Casil