473,397 Members | 1,950 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,397 software developers and data experts.

How to translate VB code InStr(1, sDocName, """") to C#

hi there, how do I translate the following vb code to C#? I know to use
Indexof, but what would be for """"? Thanks!

InStr(1, sDocName, """")
Nov 17 '05 #1
4 1943
mystring.Indexof("\"\"");

--
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.masterado.net/home/listings.aspx

"cloudx" <cl****@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
hi there, how do I translate the following vb code to C#? I know to use
Indexof, but what would be for """"? Thanks!

InStr(1, sDocName, """")

Nov 17 '05 #2
"cloudx" <cl****@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
hi there, how do I translate the following vb code to C#? I know to use
Indexof, but what would be for """"? Thanks!

InStr(1, sDocName, """")


Hi, they are looking for a double quote char in the string, so you would use
"\"" in C#. Don't forget that VB indexes are 1-based, so the equivalent
index in C# would be 0 (assuming they didn't specify Option Base 0).

-- Alan
Nov 17 '05 #3
"Robbe Morris [C# MVP]" <in**@turnkeytools.com> wrote in message
news:OO*************@TK2MSFTNGP09.phx.gbl...
mystring.Indexof("\"\"");


Hi. Should be just "\"" not "\"\"". The two "" together in VB signify one
double quote.

-- Alan
Nov 17 '05 #4
1. IndexOf's 'start' parameter is 0-based, while InStr is 1-based.
2. If you're converting existing code, then you'll also have to add 1 to the
result since InStr's result is 1-based while IndexOf's result is 0-based.

So, unless you're rewriting the surrounding code (instead of just converting
it), the correct translation is:

i = sDocName.IndexOf("\"", 0) + 1;

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"cloudx" wrote:
hi there, how do I translate the following vb code to C#? I know to use
Indexof, but what would be for """"? Thanks!

InStr(1, sDocName, """")

Nov 17 '05 #5

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

Similar topics

18
by: Phill Long | last post by:
this is the the code, now here is the final result.... I get one combo box and one tex box come up, but they are empty... DAMN!!! Any ideas on what Im doing wrong please.. Thanks Again <?php...
3
by: Graham | last post by:
On page 89 of Stroustrup's book "The C++ Programming Language" 3rd Ed. He says that multidimensional arrays are best avoided outside low-level code. What precisely does he mean by low-level...
5
by: apple | last post by:
UDBV8 fp 6a - AIX 5.1 We have scheduled cron jobs to do backups. Periodically and starting to occur more frequently, a backup fails with this error: SQL2072N Unable to bind the shared library...
6
by: Wito | last post by:
hi, I want to backup database (db2, aix 5.1) using script. When I exec script logging to user db2inst1 then is everything ok, but from cron, I get these error: SQL10007N Message "-1390" could...
1
by: kennethfine | last post by:
I'm transitioning from ASP development, please excuse these basic questions. One thing I did often in ASP was create a "translate" function to render one string to another, strip out excess...
1
by: Mitan | last post by:
Hello, I'm a beginner with what appears to be a simple question for which I haven't been able to get an answer. Can someone explain what "implementation code" is in relation to VB.NET? I want to be...
2
by: mike_li | last post by:
On Window 2000 Professional Server DB2 UDB Level: DB2 code release "SQL07029" with level identifie "030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and "WR21337". In the...
3
by: nan | last post by:
Hi All, I am trying to connect the Database which is installed in AS400 using DB2 Client Version 8 in Windows box. First i created the Catalog, then when i selected the connection type...
6
by: Nathan Sokalski | last post by:
I recently converted some ASP.NET 1.1 projects of mine, created with Visual Studio .NET 2003, to Web Application Projects in Visual Studio .NET 2005 so that I could use ASP.NET 2.0 (All my ASP.NET...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.