Visual Basic help please

Permabanned
Joined
18 Oct 2002
Posts
2,275
shadow4509 said:
i do have 1 final question about something ( i have checked all my handouts and its not on there :D ) . I have now added another command button to my application. The command button is to enter a new students details, so basically all i want it to do is clear any information entered so that the form can be reused for a new student .

Again, thanks for all your help!! Its appreciated!

txtName.text = " "
 
Associate
OP
Joined
11 Nov 2006
Posts
549
Location
Devon
ok i think i got it, not sure if there is a quicker way but it works :D


to clear the text boxes on screen i have done:

Private Sub cmdnew_Click()
txtname.Text = " "
txtsurname.Text = " "
txtclass.Text = " "
txthistory.Text = " "
txtmaths.Text = " "
txtenglish.Text = " "
txtscience.Text = " "
txtgrade.Text = " "
txttotal.Text = " "
End Sub

I believe i can now move on to my output screen, so dont go too far away from your pc's people ;)
 
Soldato
Joined
23 Dec 2002
Posts
2,806
Location
Bristol
shadow4509 said:
to clear the text boxes on screen i have done:

Private Sub cmdnew_Click()
txtname.Text = " "
txtsurname.Text = " "
txtclass.Text = " "
txthistory.Text = " "
txtmaths.Text = " "
txtenglish.Text = " "
txtscience.Text = " "
txtgrade.Text = " "
txttotal.Text = " "
End Sub

thats right if you want a space in every box and not blank them.
 
Associate
OP
Joined
11 Nov 2006
Posts
549
Location
Devon
ok what the hell, im so grateful of your help im going to ask for more. Now this is something i have never done before (really i mean i have NEVER done thid) But i want to add a little something extra.

On my output page im going to display the results entered such as total marks, grade result and then im going to display a comment such as "well done good marks!" if its a distinction. But i would also like to display a picture depending on the grade results. So if a distinction then i would like a thumbs up pictures be displayed or if fail a thumbs down picture.

Is this going to be hard?
 
Associate
OP
Joined
11 Nov 2006
Posts
549
Location
Devon
lol thanks shadez

So i have 2 pictures

Pic 1 for Fail = Thumbs down

Pic 2 for pass, merit, distinction = Thumbs up

I have to hand this is on disk to my tutor so i take it that the pictures that i use must be included on the disk?
 
Permabanned
Joined
18 Oct 2002
Posts
2,275
Yes pictures need to be on disk. Actually I think they can be embedded into the form I can't remember.
 
Last edited:
Soldato
Joined
12 Dec 2006
Posts
3,421
Location
Worthing, West Sussex
I think it depends.

If you load the picture into the picturebox using code, you need the picture on the disk.

But if you load the picture into the form by setting the properties of the picture box (you know, clickety click, no typing) then I think it embeds it into the program :)

Have a play about with it, like I say I haven't used VB6 for a while so can't remember everything :p
 
Soldato
Joined
23 Dec 2002
Posts
2,806
Location
Bristol
if you can see the picture in the box during design mode then the picture is stored in the program (this will be the way you have done it)

it is possible to dynamicly load pictures from disc and only use the one box but for what your doing its not worth it.


oh and hand it in on a disk..... what a hard disk???? :confused:
 
Associate
OP
Joined
11 Nov 2006
Posts
549
Location
Devon
lol tell me about it!!!

I have finally finished, i have given up on the displaying 1 of 2 pictures depending on grades.

Just annotating all the code now and then have to evaluate.

Does anyone know how i printout the commented code and screen dumps?

EDIT: Ok just when i thought it was all over - IT WASN'T!!!!

I have to define the class box to only accept the number 1, 2 or 3 and if another number is entered a error message is to be displayed. I know how to do the error message, i think its : MsgBox "Error Please enter 1,2 or 3!"

But im not sure how to set it to take only 1,2 or 3 can anyone point me in the right direction please?
 
Last edited:
Soldato
Joined
23 Dec 2002
Posts
2,806
Location
Bristol
several ways to do this, all trigger off events of the textbox.

The textchange or validate event are the most useful events for what you are trying to do.

Or if you want to make it realy snazzy you could lock the textbox to a updown control, use a combo box or even use radio buttons instead. :D
 
Associate
OP
Joined
11 Nov 2006
Posts
549
Location
Devon
could i not just put

If txtclass >3 Then
MsgBox "Please enter class number 1,2 or 3!"
End If

EDIT:

I have used a combo box now and have set that up without a problem, but the problem i'm having now is trying to display what the user selects on the output screen (form2).

I have used

form2.lblclassout.caption = class.text

But i dont think text should be used with a combo box so what do i need to change it to?
 
Last edited:
Soldato
Joined
23 Dec 2002
Posts
2,806
Location
Bristol
shadow4509 said:
could i not just put

If txtclass >3 Then
MsgBox "Please enter class number 1,2 or 3!"
End If


yes this is the way you would do it, some things to consider

1, what happens if they dont enter a number ie they type 'k' (have a look at isnumeric())
2, the current example just tells you to enter a valid value but lets continue anyway. You will need to clear the textbox and / or cancel any other processing you are about to do.
 
Soldato
Joined
23 Dec 2002
Posts
2,806
Location
Bristol
Using the combo.text property is fine.

Have a look at the combo's style property beacuse as default you can enter anything into the combo text box.
 
Associate
OP
Joined
11 Nov 2006
Posts
549
Location
Devon
I have changed it so that there are only 3 options available :

Class 1
Class 2
Class 3

but when using form2.lblclassout.Caption = class.text i am not getting the selection displayed on form 2

I want to cry
 
Back
Top Bottom