...

View Full Version : VB goto class command?



jack10685
02-01-2013, 12:36 AM
I am learning Visual Basic and have got it figured out to some extent, my only problem is that I am trying to make the application go to a different class if a certain variable is set to 1, how would I do this?

alykins
02-01-2013, 02:02 PM
Module Module1

Sub Main()
Dim d As New demo
d.doSomethingElse()
End Sub

End Module

Public Class demo
Sub New()
doSomething()
End Sub
Private Sub doSomething()
Console.WriteLine()
End Sub
Public Sub doSomethingElse()
Console.ReadLine()
End Sub
End Class

jack10685
02-04-2013, 08:24 PM
great god, I suck at VB. Are there any video tutorials of this anywhere on how to set it up correctly? I am trying to set it up so that if you enter a correct password, it takes you to a GUI with functions binded to certain buttons.

AceInfinity
02-05-2013, 07:27 AM
go to a different class if a certain variable is set to 1, how would I do this?

I'm confused on this, you don't really jump or "go to" a different class, classes just perform various procedures if you have methods inside of them. You have an entry point, which calls a new instance of, by default Form1, and this is where your application runs.

If, in the settings you configure it to close upon the last form, or when the first form closes, it's possible to close the form associated with the initial startup form and run code only in the next form, lets say called Form2, but typically all other classes just run code for you, simultaneously while your main Form code still runs in the background; listens for events, etc...

Instead of explaining what your problem is, and especially since you're just starting out, lets go with something a bit more appropriate so we can help you out: What are you trying to achieve?

I ask this because most of the time, the user has an issue, and because they don't truly understand how they should be doing what they are trying to do, it's either an odd way of doing it, or it's wrong.

alykins
02-05-2013, 11:53 AM
great god, I suck at VB. Are there any video tutorials of this anywhere on how to set it up correctly? I am trying to set it up so that if you enter a correct password, it takes you to a GUI with functions binded to certain buttons.

I don't know of any tutorials... I don't know how you are doing this either, but what you want to look at is the http redirect method (http://msdn.microsoft.com/en-us/library/t9dwyts4(v=vs.100).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1).

So...


If *evaluate some condition* Then
Response.Redirect("MyAuthenticatedPagePath")
Else
Response.Redirect("AuthenticationDeniedPagePath")
End If

jack10685
02-05-2013, 08:54 PM
I don't know of any tutorials... I don't know how you are doing this either, but what you want to look at is the http redirect method (http://msdn.microsoft.com/en-us/library/t9dwyts4(v=vs.100).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1).

So...


If *evaluate some condition* Then
Response.Redirect("MyAuthenticatedPagePath")
Else
Response.Redirect("AuthenticationDeniedPagePath")
End If


would the path be a class, or a different .vb file within visual studio?

AceInfinity
02-06-2013, 04:22 AM
It would be a Form class, but first you need to understand why alykins posted something about an HTTP Request for this. I believe what he's trying to do there is to do the validation trhough some online place to decide whether to show a Form?

The benefit of this is because .NET is not very secure lol... It can be decompiled quite easily. You DO NOT want to have your password validation against a plaintext password hardcoded into the app itself. Regardless, I bet you I could still get around this HTTP Request validation if I really wanted to, because all of the instructions for when and if you are validated, still exist within the app itself. It would be a simple "jmp" instruction most likely to bypass the validation completely.

If you're just beginning in .NET though, you don't have a hope of making your app 100% secure, that's all I can say. Not because you're "terrible" by any means. Protection in .NET is actually pretty complex to achieve. Actually, this is true in most other languages too. With an advanced reverse engineer you'd almost have no chance.

Lots of people choose to have an online SQL database though for validation, and your app sends a request and receives a response as to whether you are validated or not...

The data is stored as a hash, and the input from the program is hashed to compare with the hashed value in the database to test for equality. If they match, then Show the new Form(), otherwise, show an error message?

Thus you can obviously see that we need an If statement here. Hope that helps...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum