473,507 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

converting VB to C#

How can i convert this lines of codes into C#? Many thanks

for x=65 to 90
SQLHolder.text=SQLHolder.text & "<a href=""alpha.aspx?alpha=" & chr(x) &
chr(34) & _
" class=""LinkClass"">" & chr(x) & "</a> | "
next
SQLHolder.text=SQLHolder.text & " | <a href=""alpha.aspx"">All Names</a>"
End If

Jul 21 '05 #1
8 1593
Huzz,

I think I would do it like this. Where you have to check it yourself if it
is complete.
(I have the idea that your VBNet code is as not right, and would use the
same Stringbuilder in the VBNet code by the way)

\\\
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for ( int x=65; x< 91 ; x++)
{
sb.Append(@"<a href=""alpha.aspx?alpha=""");
sb.Append((char) x);
sb.Append ((char) 34);
sb.Append (@"class=""LinkClass"">");
sb.Append ((char) x);
sb.Append ("</a> |");
}
SQLHolder.Text = SQLHolder.Text + sb.ToString()
+ "<a href='alpha.aspx'>All Names</a>";
}
///

I hope this helps?

Cor
Jul 21 '05 #2
sb.Append ((char) 34);

change it to:

sb.Append("\r\n");

--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Jul 21 '05 #3
Master Gaurav

char 34 is a double quote not a carriage return & linefeed

Cor
Jul 21 '05 #4
Our Instant C# VB.NET to C# converte produces:

for (x = 65; x <= 90; x++)
{
SQLHolder.Text=SQLHolder.Text + "<a href=\"alpha.aspx?alpha=" + (char)(x)
+ (char)(34) + " class=\"LinkClass\">" + (char)(x) + "</a> | ";

}
SQLHolder.Text=SQLHolder.Text + " | <a href=\"alpha.aspx\">All Names</a>";

Download our Demo Edition to easily obtain C# equivalents for these sort of
small VB.NET code snippets (www.instantcsharp.com).

David Anton
Tangible Software Solutions Inc.
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter
"huzz" wrote:
How can i convert this lines of codes into C#? Many thanks

for x=65 to 90
SQLHolder.text=SQLHolder.text & "<a href=""alpha.aspx?alpha=" & chr(x) &
chr(34) & _
" class=""LinkClass"">" & chr(x) & "</a> | "
next
SQLHolder.text=SQLHolder.text & " | <a href=""alpha.aspx"">All Names</a>"
End If

Jul 21 '05 #5
Oops!

I got confused with chr(13) :D

Then, you'd better be using "\"" or sb.Append('"') [ ' " ' ]
:-)
You can avoid the extra step of type-casting. It's costly you see....

--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Jul 21 '05 #6
> SQLHolder.Text=SQLHolder.Text + "<a href=\"alpha.aspx?alpha=" +
(char)(x)

Avoid
(char) (x)
Prefer using:
Convert.ToChar(x)

This is unicode-safe and optimized for internationlized content. I'd
suggest using Convert class a habbit.
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Jul 21 '05 #7
Most of the time, we have chosen the C# equivalent that most closely
replicates the run-time behavior of the original VB.NET code, since
ultimately it's the run-time behavior that is most important to developers
converting code from one language to another. We'll take a look at this again
to see if Convert.ToChar is closer than a char cast.

Regards,
David Anton
Tangible Software Solutions Inc.

"MasterGaurav" wrote:
SQLHolder.Text=SQLHolder.Text + "<a href=\"alpha.aspx?alpha=" +

(char)(x)

Avoid
(char) (x)
Prefer using:
Convert.ToChar(x)

This is unicode-safe and optimized for internationlized content. I'd
suggest using Convert class a habbit.
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Jul 21 '05 #8
Thanks so much to all of you for your help.. :)

"huzz" wrote:
How can i convert this lines of codes into C#? Many thanks

for x=65 to 90
SQLHolder.text=SQLHolder.text & "<a href=""alpha.aspx?alpha=" & chr(x) &
chr(34) & _
" class=""LinkClass"">" & chr(x) & "</a> | "
next
SQLHolder.text=SQLHolder.text & " | <a href=""alpha.aspx"">All Names</a>"
End If

Jul 21 '05 #9

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

Similar topics

4
2470
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
29
3853
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant...
8
5715
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
2495
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
2398
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
2
6160
by: Map Reader | last post by:
Greetings, I am converting an old VB6 application to use .NET. One of the old controls loads icons from the disk and displays them. However, the transparent color turns to blue somewhere in the...
12
3129
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
7
2679
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
4
3173
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
2
5848
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
0
7223
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
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
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...
1
7034
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...
0
5623
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
4702
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...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
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...

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.