Visual basic coding help

Caporegime
Joined
18 Sep 2009
Posts
30,499
Location
Dormanstown.
Hey.
I'm currently doing a HCI assignment which has us using VB, the teacher doesn't mind if the code's not original, he only cares about the presentation.
But given his bland explanation of presentation, it's very varied.
Anyways.

The program that we're to create is a reactions test.

Currently, my programs consists of these forms ;

My splash page
1290597292.png


My main page

1290597394.png


My options page

1290597435.png


My help page

1290597527.png


The reactions test page (You'll realise while it's blank)

1290597582.png


My results page

1290598107.png



What the program currently does ;

When you start the program, it'll load up frmSplash (As it should), that will take you to frmMain (As it should). The user can then go onto frmOptions and select the background and text colour (Becomes apparent later), they can then go back to frmMain, and then onto frmHelp, and then back to frmMain.

Anyways, then when the game is started on frmReactionsTest, the lblTest will load up the colour that you've chosen in frmOptions.

This is where it gets tricky, and I'm stuck. I must make the letter A appear around different locations of lblTest 20 times at 3 second intervals after the space bar has been pressed. Each time the letter A appears there should be a counter, which is then stopped after the space bar is pressed. And it'll continue on the next letter A appearing.

After 20 times it should average your time it took per click, and those results should be displayed in frmResults.

I have NO idea how to do this, and neither does our coding (Not HCI) teacher, hell, selecting the colours our coding teacher used ridiculously complicated coding with highlighting etc, when mine does the same thing with about 10 times less coding.

So, any coding guru's can help :p?

I'll send you my .rar which has my Visualbasic project, along with all my images.
 
could help, but dont know when I will be able to look at it, if you send it to my email in trust I will load it up :)

Stelly
 
Make the label small, position it with .top and .left, use rnd() multiplied by the form width / height, you'll get the idea.

timer control

declare variables at the top of the form or in a module, this will persist and let you tot up the totals for all clicks.

If you're having problems registering the keypress look at the keypreview property of the form.
 
could help, but dont know when I will be able to look at it, if you send it to my email in trust I will load it up :)

Stelly

I've E-mailed you cheers.


Make the label small, position it with .top and .left, use rnd() multiplied by the form width / height, you'll get the idea.

timer control

declare variables at the top of the form or in a module, this will persist and let you tot up the totals for all clicks.

If you're having problems registering the keypress look at the keypreview property of the form.

I'll do that now.
Forgot to say it's VB 6.0, whatever implication that has on the syntax.
 
If you're doing an HCI module you need to change your blue/black colour combination. The first thing we got drilled into us when we did HCI was about colour contrast. Dark blue and black text (and especially that font) are hard to read. You need to design the interface so that it's very clear- large buttons, clear text, good colour contrasts. Write about all this and you should score well.

I used Contrast Analyser which although is targeted for websites works well. It gives you a colour picker- one for the background colour and one for the foreground colour and analyses the colours to give you a contrast rating. It also lets you simulate your application how people with various forms of colour blindness would see it.
 
This is where it gets tricky, and I'm stuck. I must make the letter A appear around different locations of lblTest 20 times at 3 second intervals after the space bar has been pressed. Each time the letter A appears there should be a counter, which is then stopped after the space bar is pressed. And it'll continue on the next letter A appearing.

This sounds pretty simple, but it seems like you probably want to move the lblTest label (which displays the letter 'A') around the screen rather than move the letter 'A' within the label. To do this simply set the Top and Left properties of the label to some random fraction of the ScaleWidth and ScaleHeight properties of the form. The following does most of what you want, you'll need to implement a counter to restrict the reaction test to 20 times and hold each time value in an array so you can calculate the average.

Note the Timer() function has a pretty low resolution, about 1/18 of a second. If you want to significantly improve that you'll need to use the QueryPerformanceCounter() API, there's load of code for this on the web.

Code:
' Code in frmReactionsTest

Private sngStartTime As Single
Private sngReactionTime As Single

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If lblTest.Visible = True Then
        ' Claculate elapsed time (ought to handle the roll-over here)
        sngReactionTime = Timer() - sngStartTime
        ' Display it in the caption
        frmReactionsTest.Caption = sngReactionTime
        ' Hide the label
        lblTest.Visible = False
    Else
        ' User pressed key before label was displayed.
        frmReactionsTest.Caption = "Cheat"
    End If
End Sub

Private Sub Timer1_Timer()
    ' If label is visible here the user took more than 3 seconds.
    If lblTest.Visible = True Then
        frmReactionsTest.Caption = "Too slow!"
    End If
    ' Move label to new random position
    lblTest.Top = (frmReactionsTest.ScaleHeight - lblTest.Height) * Rnd()
    lblTest.Left = (frmReactionsTest.ScaleWidth - lblTest.Width) * Rnd()
    ' Show the label
    lblTest.Visible = True
    ' Get the start time
    sngStartTime = Timer()
End Sub
 
Agreeed colour scheme is hard to read. Change black text to white. (or use light blue which will look crapier).

I would consider moving to vb.net aswell.

should be able to download a express product for free.
 
Back
Top Bottom