473,698 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check the first 2 characters of string

Hi Group,
How can I check that the first 2 characters of a string are the percent (%)
sign?
string name = strSurname

Regards

Jul 30 '08 #1
6 25124
On Jul 30, 12:22 pm, "axapta" <jas.jac...@gma il.comwrote:
Hi Group,
How can I check that the first 2 characters of a string are the percent (%)
sign?
string name = strSurname

Regards
strSurname.Star tsWith("%")
Jul 30 '08 #2
On Jul 30, 12:22 pm, "axapta" <jas.jac...@gma il.comwrote:
Hi Group,
How can I check that the first 2 characters of a string are the percent (%)
sign?
string name = strSurname

Regards
strSurname.Star tsWith("%%")
Jul 30 '08 #3
On Jul 30, 8:22 pm, "axapta" <jas.jac...@gma il.comwrote:
Hi Group,
How can I check that the first 2 characters of a string are the percent (%)
sign?
string name = strSurname

Regards
You can get first two chars of a string with substring method like
below:

Dim foo As String = "foo"
'outputs "fo"
foo = foo.Substring(0 , 2)

However, i'm not sure why you're looking for first 2 chars of the
string for determining if describes a percentage.

For example, you can use StartsWith("%") function depending on your
implementation of your application.

Thanks,

Onur


Jul 30 '08 #4
Please always check the documentation before posting. For example try :
http://msdn.microsoft.com/en-us/libr...tartswith.aspx.
Intellisense should have also shown what you could do with a string
(http://msdn.microsoft.com/en-us/libr...b(vs.71).aspx)...

As you seems to be a beginner you may want also to read the language
specification once (not sure which one you are suing as you post what seems
an erroneous c# line in a vb group).

Finally in case you would have some sort of error ( do you miss the final ;
character in your code ?) post about the error you got rather than asking
such a general and basic question...

--
Patrice

"axapta" <ja********@gma il.coma écrit dans le message de groupe de
discussion : D0************* *************** **...icrosof t.com...
Hi Group,
How can I check that the first 2 characters of a string are the percent
(%) sign?
string name = strSurname

Regards

Jul 30 '08 #5
On Wed, 30 Jul 2008 18:22:09 +0100, "axapta" <ja********@gma il.com>
wrote:
>Hi Group,
How can I check that the first 2 characters of a string are the percent (%)
sign?
string name = strSurname

Regards
If Mid(mystring, 1, 2) = "%%" Then
'Do whatever
End If
Jul 30 '08 #6
"Kevinp" <kmahoney@nospa m_fireacademy.o rgschrieb:
>>How can I check that the first 2 characters of a string are the percent
(%)
sign?
string name = strSurname

Regards

If Mid(mystring, 1, 2) = "%%" Then
'Do whatever
End If
VB6-style: 'If Left(MyString, 2) = "%%" Then...'. You could also use the
'Like' string comparison operator with an appropriate pattern. However, I
doubt that these solutions are better than 'String.StartsW ith'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jul 30 '08 #7

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

Similar topics

9
19693
by: Henke | last post by:
Hi! Is there a simple way to check if a string entered in a text box is a valid integer? Thanks in advance! /Henke
4
34552
by: Hamed | last post by:
Hello How can I check if a string is empty? Thanks
7
13988
by: zjut | last post by:
I need to implement the method : round(String name, int index) The given string maybe the every type of float type, ( the msdn given the regax is that : integral-digits]exponential-digits]) and the index is the location after "." in name. First, i should check the given name is a valid float-point, and then, to check the number in name in index locaion is > 0 or not? eg:
1
3159
by: Lala | last post by:
Hi, I need to check if a string contains unicode characters, and generate an alert if it does. (I do not want to parse the string to unicode). Anyone who knows how to do this? Thanks! :D
35
75195
by: pinkfloydhomer | last post by:
How do I check if a string contains (can be converted to) an int? I want to do one thing if I am parsing and integer, and another if not. /David
3
9916
by: kathy | last post by:
I want to know what is the easy way to check if a string is a number or not? the number can be int, float, double, scientific,... what is the easy way for only interger?
6
8422
by: garyusenet | last post by:
Hello, Can someone tell me how to check if a string variable starts with a dash. ' - ' Thanks, Gary.
31
88600
by: noagbodjivictor | last post by:
How to check if a string is empty in python? if(s == "") ??
8
5742
by: danon | last post by:
Hi evrey one needing you're hlp please can any one tel me how to programme a first characters uppercase in textbox thank you
21
12031
by: Yoni Hasid | last post by:
Hello, I am trying to match tables into a query based on 5 first characters in one field. I used expression: =left(), 5) however it does not return matched entries as I needed. Basically, I need to tell query match two fields based on first characters and and show all records from Table 1 and only those records from table 2 where first 5 letters of the fields are matching. Here is my SQL from the query: SELECT .,...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9027
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
8895
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
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
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
4369
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
3046
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
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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.