I'm very new to VB this is my first attempt at a project.

basically i want a simple program that will display a famous singers surname in a text box, then ask the user to input the singers first name in another box. The system must then check the answer in relation to the values stored inside a 2D array. it should then give the user 1 point for a correct answer.

Does anyone have any ideas where i's start or any sample programs that can point me in the right direction.


The first thing is to decide where to store your array data, in code, an ini file or in a database. For the purposes of simplicity we will use code an two simple arrays, one for the question (surname) and one for the answer (first name).

At module level in the form define the following

Private strSurnames(2) as String
Private strFirstName(2) as String

On form load do the following

strSurname(0) = "Dillon"
strFirstName(0) = "Bob"

strSurname(1) = "Lennon"
strFirstName(1) = "John"

strSurname(2) = "Jagger"
strFirstName(2) = "Mick"

Then in a function for the start button do the following

For i = 0 to uBound(strSurname)

strAnswer = trim$(inputbox("Enter the first name for " & strSurname(i)))
If LCase(strAnswer) = LCase(strFirstName) Then
intScore = intScore + 1
End If

Next i

That should cover the basics



excuse my arrogance even after a quick google serach i cannot work out what "module level" is and where to find it. I assume "on form load" simply means The area under where it says "public class Form 1"


Basically all code in VB is placed in one of three containers

1. Forms
2. Modules
3. Classes

Forms and Classes can be used to conform with the majority of OO design, excluding principally inheritance. Modules sit outside that as separate peices of code. Despite the name module level variables are actually just variables placed within any of these containers, but outside of any functions or subs. Also module level variables are defined as Private, and hence only usable within that container.

In the case of your problem the container would be a form and the variables would be defined at the top of the form code before any functions.

Form load is an event function, at the top of the vb code window when looking at your form there are two drop down boxes, the first for objects and the second for events that can occur on those objects (if (General) is selected then the containers functions and subroutines are listed). These boxes have a dual purpose, to easily navigate to the desired function and to create the shell of event handlers. In order to create the form load event do the following

1. Open the code window for your form
2. Select Form from the object box
3. Select Load from the event box

This will either take you to an already created Load event, or create an empty procedure to handle that event.

Having said all that to make it easy you could just put the whole thing under the click event of your command button. But it's best to learn this stuff anyway.

ohh man i've bitten off more than i can chew, thanks for this explanation its made it a bit clearer, but i'm still no nearer in knowing how to progress

I'm still finding this very difficult does anyone have a working piece of code in actual vb.net project that i could download & have a look at thanks

If you are using .Net that will change much of what I said in the previous post, you may want to post in the .Net forum and let the guys over there help you out



can you tell me what would change, i have encountered the original version of visual basic years ago but i dont understand this vb.net.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.