Visual Basic

Associate
Joined
2 Nov 2008
Posts
790
I got Visual basic 2005 and am stuck trying to find the code to close one form and open another at the push of a button.

Is there any easy way to do this?

Assuming both forms are Form1.vb and Form2.vb are there any easy commands like

Open.Form2.vb etc?

Thanks
 
Any chance there are any easy to understand guides on how to use the lookup function in visual basic, too?

I have sorted the page changing, now I can't get VB to look up a file from a 2 dimensional array.
In this case what I am looking for is something input from a text box.

Thanks again :D
 
Well, I'm trying to lookup something from an array. I don't necessarily need to 'find' anything. It's just a case of if 'x' is in the array then let them go on to the next page.

A very simple password, basically :P
 
Code:
Dim pwList() As String = {"password", "pass123", "fred"}
        If Array.IndexOf(pwList, "fred") > 0 Then
            'do stuff
        End If

You can use Array.Exists but that's a bit more advanced.
 
Code:
Dim pwList() As String = {"password", "pass123", "fred"}
        If Array.IndexOf(pwList, "fred") > 0 Then
            'do stuff
        End If

You can use Array.Exists but that's a bit more advanced.

Thanks :D

I just tried it and.
The array i'm using is 2 dimensional. Also the program doesn't like the > 0

Will the 2 dimensional factor make a large difference?
 
Last edited:
Yeah, missed the 2d bit! It will make a vast difference.

Code:
        Dim user As String = "freddy"
        Dim pwd As String = "fred"

        Dim pwList(,) As String = {{"Rod", "password"}, {"Jane", "pass123"}, {"freddy", "fred"}}

        For i As Integer = 0 To pwList.GetUpperBound(0)
            If pwList(i, 0).Equals(user) AndAlso pwList(i, 1).Equals(pwd) Then
                'do stuff
                Exit For
            End If
        Next
 
Back
Top Bottom