Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help: Convert some C# to VB.NET

0 views
Skip to first unread message

Charles

unread,
May 20, 2003, 5:27:49 PM5/20/03
to
Jesse Sweetland send me this example to clear my asp page
but I'm a VB kind of guy.
/// <summary>
/// This is the event delegate that gets called when you
need
/// to clear your form
/// </summary>
public void Button1_Click( object sender, EventArgs e )
{foreach( Control control in this.Controls )
{ if( control.ID.StartsWith( "special_" ) )
{if( control is TextBox )
{((TextBox)control).Text = "";
}elseif( control is DropDownList )
{((DropDownList)control).ClearSelection();
}
}
}
}


Steve C. Orr, MCSD

unread,
May 20, 2003, 6:05:21 PM5/20/03
to
This should do it:

Dim ctrl as Control
For each ctrl in me.controls
If ctrl.ID.StartsWith("special_") Then
If Typeof ctrl is TextBox then
Ctype(ctrl,TextBox).Text=""
Else
If TypeOf ctrl is DropDownList Then
CType(ctrl,DropDownList).ClearSelection()
End If
End If
End If
Next

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net


"Charles" <CWil...@Bellsouth.net> wrote in message
news:0cac01c31f16$a9f23430$a001...@phx.gbl...

Charles Wildner

unread,
May 20, 2003, 6:29:40 PM5/20/03
to

Steve,
I the code is in ASP.NET in VB is it still the same??


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Steve C. Orr, MCSD

unread,
May 20, 2003, 9:01:31 PM5/20/03
to
The code I listed should work with ASP.NET, if that's what you were trying
to ask...

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net


"Charles Wildner" <cwil...@bellsouth.net> wrote in message
news:uWjfO9x...@tk2msftngp13.phx.gbl...

Charles Wildner

unread,
May 20, 2003, 9:49:08 PM5/20/03
to

Steve,

I'm getting
("Object reference not set to an instance of an object.")
on the "If ctrl.ID.StartsWith("txt") Then" line
and if I leave it out it only loops thru 3 times and then
stops. there are atleast 20+ controls on the ASP page

Charles

Kevin Spencer

unread,
May 21, 2003, 9:58:33 AM5/21/03
to
Steve translated the code you supplied, from C# to VB.Net. If it doesn't
work, check with the guy who gave you the original code to start with.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
A watched clock never boils.

"Charles Wildner" <cwil...@bellsouth.net> wrote in message

news:eqkPsszH...@tk2msftngp13.phx.gbl...

Bavo Ketels

unread,
May 21, 2003, 10:08:14 AM5/21/03
to
Dim ctrl as New Control?

"Charles Wildner" <cwil...@bellsouth.net> schreef in bericht
news:eqkPsszH...@tk2msftngp13.phx.gbl...

Felix Wu [MSFT]

unread,
May 22, 2003, 10:34:40 PM5/22/03
to
Hi Charles,

In case you need to convert other C# code to VB.NET, the following
converter should help in most cases:

http://www.kamalpatel.net/ConvertCSharp2VB.aspx

Hope this helps.

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>From: Charles Wildner <cwil...@bellsouth.net>
>References: <e#meGSzHD...@TK2MSFTNGP11.phx.gbl>
>X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
>Subject: Re: Convert some C# to VB.NET
>Mime-Version: 1.0
>Content-Type: text/plain; charset="us-ascii"
>Content-Transfer-Encoding: 7bit
>Message-ID: <eqkPsszH...@tk2msftngp13.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Date: Tue, 20 May 2003 18:49:08 -0700
>NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
>Lines: 1
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:146747
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

0 new messages