Translate to VB.NET


Edited by SomeNewKid. Please post code between <code> and </code> tags.


How does this translate to VB.NET:
public int CurrentPage

{
get
{
// look for current page in ViewState
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0; // default page index of 0
else
return (int) o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}

Jean-Luc


www.corobori.com
-1
Corobori
2/23/2005 5:48:07 PM
asp.net.getting-started 91979 articles. 2 followers. Follow

6 Replies
548 Views

Similar Articles

[PageSpeed] 30

Public Property CurrentPage() As Integer

Get
' look for current page in ViewState
Dim o As Object = Me.ViewState("_CurrentPage")
If o Is Nothing Then
Return 0 ' default page index of 0
Else
Return CInt(o)
End If
End Get
Set
Me.ViewState("_CurrentPage") = value
End Set
End Property

This code is thanks to Alex Lowe's C# to VB.NET Translator.
You may want to bookmark that webpage.
Alister
-1
SomeNewKid
2/23/2005 6:04:33 PM
You can often use reflector, it has a snap in for the VS IDE.  It can give you an idea of what things look like in an alternate language.

Those who say it can not be done, should not interrupt those who are doing it!
-1
jrandomuser
2/23/2005 7:33:33 PM
Sorry for forgetting to tag my code.

Thanks to translate. Still need to understand what viewstate is.
Jean-Luc


www.corobori.com
-1
Corobori
2/23/2005 9:25:55 PM
viewstate is nothing but a hidden field,that the server controls regain their initial state (previous text, selection, etc..) upon postback.

Once a post back happens, the page will look at the viewstate of the webpage to get the values for the controls from
regards
Bilal Hadiar, MCP, MCTS, MCPD, MCT
Microsoft MVP - Telerik MVP
1
haidar_bilal
2/23/2005 9:29:55 PM
I am trying to do what shown in http://aspnet.4guysfromrolla.com/demos/TestRepeater.aspx but using vb.net. It seems that something is wrong because when running the page I am seeing all rows and not only 3 as I expected


Imports System.Data
Imports System.Data.OleDb
Imports System.Web.UI.WebControls
Public Class faq
Inherits System.Web.UI.Page
Dim con As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Inetpub\wwwroot" & _
"\sodiIT\_Private\faq.mdb"
Dim objConn As New OleDbConnection(con)
Dim objDA As OleDbDataAdapter
Protected WithEvents rptItem As System.Web.UI.WebControls.Repeater
Protected WithEvents frmTest As System.Web.UI.HtmlControls.HtmlForm
Dim objDS As New DataSet
Protected WithEvents cmdNext As System.Web.UI.WebControls.Button
Protected WithEvents cmdPrev As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents repeaterItems As System.Web.UI.WebControls.Repeater
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Public Property CurrentPage() As Integer
Get
Dim o As Object = Me.ViewState("_CurrentPage")
If o Is Nothing Then
Return 0 ' default page index of 0
Else
Return CInt(o)
End If
End Get
Set(ByVal Value As Integer)
Me.ViewState("_CurrentPage") = Value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BindData()
End Sub
Sub BindData()
Const sFName As String = "Usuarios BindData"
Dim objPds As New PagedDataSource
objDA = New OleDbDataAdapter("Select * from tblFAQ", objConn)
objDA.Fill(objDS, "FAQ")
objPds.DataSource = objDS.Tables(0).DefaultView
objPds.AllowPaging = True
objPds.PageSize = 3
objPds.CurrentPageIndex = CurrentPage
If objPds.IsFirstPage Then
cmdPrev.Enabled = False
Else
cmdPrev.Enabled = True
End If
If objPds.IsLastPage Then
cmdNext.Enabled = False
Else
cmdNext.Enabled = True
End If
rptItem.DataSource = objDS
rptItem.DataBind()
End Sub
Private Sub cmdNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdNext.Click
CurrentPage = CurrentPage + 1
BindData()
End Sub
Private Sub cmdPrev_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdPrev.Click
CurrentPage = CurrentPage - 1
BindData()
End Sub
End Class

Jean-Luc


www.corobori.com
1
Corobori
2/23/2005 9:49:17 PM

Thanks Jrandomuser for helping him.

My question is "Where to find snap in name 'Reflector' in VS IDE? "

Otherone is "Is there any tool that translate C# code to VB automatically?"

Regards

Ali



_____________________________________
"Struggle is antoher name of life."
-1
gul52470
5/9/2005 1:38:13 AM
Reply:

Web resources about - Translate to VB.NET - asp.net.getting-started

File:Google Translate.PNG - Wikipedia, the free encyclopedia
This image is a screenshot of a copyrighted web page , and the copyright for it is most likely held by owner of the website. It may also contain ...

Report: Success On The Field For MLB Teams Translates Into Success On Facebook
Success on the field translates into success in terms of adding Facebook likes for Major League Baseball teams, according to a new analysis from ...

CSS Hat translates Photoshop layer styles to CSS3
This will be a huge hit. ∞ Read this on The Loop

Facebook-connected fitness apps translate into real life success
Fitness applications are growing in popularity — largely because they work well, especially when a user connects the app to their Facebook account. ...

Twitter Blog: It takes a community to translate Twitter
Twitter Blog It takes a community to translate Twitter 5355886907516812597 Monday, August 01, 2011 Twitter celebrated its first non-English launch ...

TransMate ~ Google translate and offline dictionary on the App Store on iTunes
Get TransMate ~ Google translate and offline dictionary on the App Store. See screenshots and ratings, and read customer reviews.

translate suggest - Flickr - Photo Sharing!
Explore jensminor's photos on Flickr. jensminor has uploaded 1567 photos to Flickr.

Terror laws: Baird government says 28 days needed to translate foreign languages, IT
Delays in investigating social media, foreign translation and gathering international evidence given as reasons justifying extension.

Google Translate adds iPad Split View, printed text translations for more languages
Google is rolling out a couple notable updates to its Google Translate apps that adds additional languages for translations of printed text and ...

Ford, Domino's, Dell, Others Work to Translate the Language of Emojis
Dell employed them for back-to-school marketing, Ford used them to promote its latest Focus model, and Domino's has invested in them to revolutionize ...

Resources last updated: 12/18/2015 10:46:55 PM