473,699 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#->VB Snippet Translation Help Needed

Hi.
I'm having trouble translating a routine to alter validation at the client
and the server.

A portion of the C# code is:
>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>> namespace Test.WebControl s
{

public class WebPage : System.Web.UI.P age
{
public WebPage()
{
validatorAssign ments = new NameValueCollec tion();
}

private void Page_Load( object sender, System.EventArg s e )
{
if( this.validatorA ssignments != null &&
this.validatorA ssignments.HasK eys() )
{
StringBuilder sb = new StringBuilder() ;
sb.Append("<scr ipt>");
sb.Append(Envir onment.NewLine) ;
sb.Append("Page _ValidatorAssig nments = true;");
sb.Append(Envir onment.NewLine) ;
for( int i = 0; i < this.validatorA ssignments.Coun t; i++ )
{
if( this.validatorA ssignments.Keys[i].ToString() != string.Empty &&
this.validatorA ssignments[i].ToString() != string.Empty )
{
sb.AppendFormat (" var {0}Validators = new Array(",
this.validatorA ssignments.Keys[i].ToString());
string[] keys = this.validatorA ssignments[i].Split(",".ToCh arArray());
for( int k = 0; k < keys.Length; k++ )
{
sb.AppendFormat ("'document. all[\"{0}\"]'", keys[k].Trim()); ///This
Line has Problems

if( k != keys.Length - 1 )
sb.Append(",");
}
sb.Append(");") ;
sb.Append(Envir onment.NewLine) ;

}
}
sb.Append(Envir onment.NewLine) ;
sb.Append("</script>");
Page.RegisterCl ientScriptBlock ("ValidatorAssi gnments", sb.ToString());
}
}
<<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <

The problem is with the line:
sb.AppendFormat ("'document. all[\"{0}\"]'", keys[k].Trim());

The error reads "Overload resolution failed because no accessible
AppendFormat can be called with these arguments....."

Any help would be appreciated

My VB translation up to that line reads:
>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>


If (Me.validatorAs signments Is Nothing) AndAlso
(Me.validatorAs signments.HasKe ys() = True) Then

Dim sB As New StringBuilder

sB.Append("<scr ipt>")

sB.Append(Envir onment.NewLine)

sB.Append("Page _ValidatorAssig nments = true;")

sB.Append(Envir onment.NewLine)

Dim i, j As Integer

For i = 0 To Me.validatorAss ignments.Count - 1

If Me.validatorAss ignments.Keys(i ).ToString <> "" AndAlso
Me.validatorAss ignments(i).ToS tring <> "" Then

sB.AppendFormat (" var {0}Validators = new Array(",
Me.validatorAss ignments.Keys(i ).ToString())

Dim keys As String() = Me.validatorAss ignments(i).Spl it(",".ToCharAr ray())

For j = 0 To keys.Length - 1

sb.AppendFormat ("'document. all[\"{0}\"]'", keys(j).Trim())

Next

End If

Next

End If

<<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<
Nov 21 '05 #1
2 1194
Phil,
\" (single quote) is in VBNet "" (double quote)

Therefore
"""This""" is "This"

I hope this helps,

Cor
Nov 21 '05 #2
Thanks for saving my skin Cor,
I should remember that backslash escapes are strictly C language type
constructs.
I learned C from K&R and used it more in the past than VB,
so when I translate C# to VB I frequently think things look ok. I
remember now constructing sql queries in regular asp vbscript
and having to concatenate strings and escape the single quotes too.

I learned .Net in VB, so I started this project with it.
In the future I'm going to do everything in C# so I don't
get a headache ;-)

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #3

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

Similar topics

22
2550
by: ByteSize | last post by:
Dear All, Please, this is not meant to be offensive - but it is a challenge !!! I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING snippet to demonsrate a successful api call to CreateProcess() using VB.NET. So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to...
7
5111
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting normal functions in header files results in multiple definition errors even when include guards are used. -- STH Hatton's Law: "There is only One inviolable Law" KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com Mozilla:...
11
1471
by: alcastle | last post by:
I'm new to C. I have a snippet of code that works, but it's a little off in the output. I'm hoping someone can spot my error(s). I'm reading input from a serial device, and I need to print Hex, which is working but I'm getting unreliable output and have formating issues. Example output: FF00000033 FF00000036 FF00000030 FF00000030 FF00000054 FF0000001A FF0000000F FF00000048 FF00000003 FF0000004A FF00000020 FF00000003 FF00000000...
25
1818
by: Sharrukin Amiri | last post by:
Hello, I am using VB 6.0 for many years. Everytime I needed to build software applications, I just opened VB 6.0 and started coding. I am now looking VB.NET Express Edition and I find I can no longer do this very easily. I find that there is too much copy and paste of code in order to get an app running. I also find it slow. Is it me or I am missing something? Here is a sample of my coding which you could find at: ...
17
2784
by: Mark | last post by:
I must create a routine that finds tokens in small, arbitrary VB code snippets. For example, it might have to find all occurrences of {Formula} I was thinking that using regular expressions might be a neat way to solve this, but I am new to them. Can anyone give me a hint here? The catch is, it must only find tokens that are not quoted and not commented; examples follow
14
1793
by: John Smith | last post by:
Can someone convert from C# into VB this line for me: if (c is System.Web.UI.HtmlControls.HtmlForm)
0
3667
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. · When was the first version of .NET released? The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on...
0
1651
by: Nolanclark | last post by:
Hi there. I've read a previous thread regarding the Old VB 6 checkbox array and how it's not really needed any more. That's fine, but I'm not really sure how to implement the checkbox control array in .NET. I am using an ARCGIS map control which has "Layers" of spatial data (i.e. Roads, Creeks, Rivers, etc.) When I load the form and the map control, I want to create a Dynamic Table of Contents in the form of Check Boxes in order to control...
4
1113
by: EricW | last post by:
Hi, I found the following code in a FAQ about the datagridview. But I am having a hard time translating it to VB, so I would like to ask via here for someone more experienced to translate this code to VB. When I can read it in VB I want to replace everything about the image into a button. Thanks in advance! Eric.
1
1496
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I'm getting a little confused here. I have a C# class that I'm trying to translate to VB. The C# class is essentially: public static class Class1 { ..... some private static variables and public static properties. } The translation (from several different translation programs) is:
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9032
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
8908
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
8880
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...
1
6532
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
5869
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
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
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
3
2008
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.