Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In VB.NET is there an Exit Sub function/command? 1

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
Basically, can I use that, or just stick with a Do While or Do Until function?
 
yup. Exit Sub

You said that you have VS but don't use it? I suggest that you try it out. You'll find just with the intellisense alone that alot of the questions you are asking won't need to be asked. That'l do donkey, that'l do
[bravo] Mark
 
okay, so I start/create a new Project... can I just point it to my website? Will it damage my current site? Very nervous... But I believe you... so here goes.
 
When you create a new web project it'll make a folder on
Copy your files into that folder

In VS under the Project menu choose to "view all files"

All your current stuff will be there. Now just select them all and right click choose Include in Project. Now whenever you open the project you will see all your files.

As you Include the aspx files in your project it will ask you if you want to create a class file for the page as it doesn't yet have one. When you do this the following line is added to the current page.
<%@ Page Language=&quot;vb&quot; Debug=&quot;True&quot; CodeBehind=&quot;HTMLPage1.aspx.vb&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;WebTEster.HTMLPage1&quot; %>

With different names of course. You then just move your inline code to the class file. I am not sure if tweaks will need to be made or not.

Of course you may choose to leave your current pages as are and build the new ones with code behind. Up to you.

For new pages use the add - items - web form from the project menu.
These new web forms will automatically be built with code behind. You can program the web form very similiar to a VB app.

I wasn't sure where you were on this so I tried to keep it simple

Good luck That'l do donkey, that'l do
[bravo] Mark
 
Thanks... going along well now... tho I did have a few snags...
Doing what you said did just as you said... But, my page doesn't work tho.
I had to change this:
Code:
<%@ Page Language=&quot;vb&quot; Debug=&quot;true&quot; CodeBehind=&quot;menu.aspx.vb&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;localhost.menu&quot; %>

To this:
Code:
<%@ Page Language=&quot;vb&quot; Debug=&quot;true&quot; Src=&quot;menu.aspx.vb&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;menu&quot; %>

Kewl, up it comes... next tho, I try to put the code into the codebehind. 3 lines of code, specify text for 3 different labels. But it says the labels are not declared (Compilation error):
Code:
Public Class menu
    Inherits System.Web.UI.Page

#Region &quot; Web Form Designer Generated Code &quot;

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    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

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Request.Cookies(&quot;time&quot;).Value <> &quot;&quot; Then timeOn.text = Request.Cookies(&quot;time&quot;).Value
        timeNow.text = Now()
        If Request.Cookies(&quot;time&quot;).Value <> &quot;&quot; Then timeLeft.text = DateDiff(&quot;n&quot;, Request.Cookies(&quot;time&quot;).Value, DateTime.Now())
    End Sub

End Class
 
Nevermind that last one. You have to declare them as Public Labels in the Codebehind, even tho they are already in the page. You don't have to do this with <script> code... okay... no prob. I see. And I got my time difference thing worked out too...
Code:
If Request.Cookies(&quot;time&quot;).Value <> &quot;&quot; Then
 diff = DateTime.Now().Subtract(Request.Cookies(&quot;time&quot;).Value)
 timeLeft.Text = diff.Minutes.ToString
End If
 
Funny that you had to do it manual. When I tested it. I included a aspx inline page to the project said yes to the create class file message and all of my labels etc were declared in the class file automatically.

Anyway here is the syntax of a label declaration. It's not public but protected
Protected WithEvents label1 As System.Web.UI.WebControls.Label


HTH That'l do donkey, that'l do
[bravo] Mark
 
Hmmm... Which version of .Net are you running? I only have Visual Basic Standard. Also, why Protected? It still works with Public. I supose I should look in more detailed about the properties of the various declaration types.
 
Yes it does work but you don't want anyone to be able to access the web form variables in that class so you make them protected.

I have Visual Studio Pro I think it is.

You'll notice if you add new controls to the page that they will be declared automatically as well. That'l do donkey, that'l do
[bravo] Mark
 
K, and as for the WithEvents? That allows events to happen to those items?
 
ya so that when you add a Handles button1.click it'll work That'l do donkey, that'l do
[bravo] Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top