Saturday, March 24, 2012

Newbie help - from C# --> VB

Can anyone please help me converting this simple C# to VB?
Many thanks in advance! Still trying to get into this fancy smancy
ASP .NET thingy from classic ASP :-0

**************************************************
private string _currentPage;

public string CurrentPage
{
get
{
return _currentPage;
}
set
{
_currentPage = value;
}
}

protected void Page_Load( object sender, EventArgs e )
{
if (CurrentPage != null)
{
WebControl currentPageControl = (WebControl)this.FindControl( CurrentPage );
}
}
*************************************************Hi,

taken thisC# to VB.NET converter it displayed this output:


Public Class abcd
Private _currentPage As String

Public Property CurrentPage() As String
Get
Return _currentPage
End Get
Set
_currentPage = value
End Set
End Property

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not (CurrentPage Is Nothing) Then
Dim currentPageControl As WebControl = CType(Me.FindControl(CurrentPage), WebControl)
End If
End Sub

BTW, if you post some code please use the tags that are used on these forums:view post 98605.

Grz, Kris.
Not too sure about the last line, as I'm not sure what you're trying to do, but:


Private strCurrentPage As String

Public Property CurrentPage() As String
Get
Return strCurrentPage
End Get
Set(ByVal Value As String)
strCurrentPage = Value
End Set
End Property

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If CurrentPage <> "" Then
' Whatever the last line does
End If
End Sub

Is that right?
Thanks to you both - just what I needed!
Will try to remember that code tag the next time :-)

0 comments:

Post a Comment