Good day to everyone:) , i'm a new user here and i'm also new to Visual Basic , i'm having problems coding the codes myself. It's an assignment for me from school , after attemtping it for a few hours , I'm almost finish but i'm having trouble in the calculation for average , you see. I feel so tiny in this world when i get to know that there's still more for me to learn. Sorry for my long story but what i'm trying to say is that i hope to learn more. I'll show you guys the codes of mine now, i think this assignment is easy for you guys so i was hesitating at first to post or not but i posted anyway , anyone can teach me what to do? thank you so much for helping!:)

And I'm also having problem with the MsgBox where i need to write the code to notify me like " Please enter integers! " , the teacher would want to test on that availablity either it is present or not.

Oh boy...i feel so troublesome to keep on asking so much...

Codes :

Dim exam1 As Integer
Dim exam2 As Integer
Dim Average As Integer
Private Sub Command1_Click()

exam1 = Text1.Text
exam2 = Text2.Text
Average = Label5.Caption
Average = (exam1 + exam2) / 2
exam1 = (Text1.Text)
If IsNumeric(Text1.Text) Then
exam1 = Text1.Text
Else
MsgBox "Please enter integers!"
End If
exam2 = (Text2.Text)
If IsNumeric(Text2.Text) Then
exam1 = Text2.Text
Else
MsgBox "Please enter integers!"
End If
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Label5.Caption = ""
End Sub

Private Sub Command3_Click()
If MsgBox("Are you sure you want to quit?", vbYesNo + vbQuestion, "Confirmation") = vbYes Then
End
End If
End Sub

I wanted to post a picture of my interface but it kept on saying here that " failed to upload bmp "...

Thank you everyone for your help!

Recommended Answers

All 3 Replies

USE JPG , BMP ARE VERY HEAVY.

exam1 = Text1.Text   What are u doing, exam1 is integer user can give alpahbets

If IsNumeric(Text1.Text) Then  you are checking after assignement.
exam1 = Text1.Text

It seems to me that you know the commands, but you've got the order messed up.

Decide the flow of your program and then put your commands in the appropriate order.
For example: Check if Text1.text is numeric, check if text2.text is numeric....
and then execute
if isnumeric(text1.text)
then
....


PS: The average of 2 integers doesn't have to be a 3rd integer. Also the isnumeric() = true doesn't mean it's an integer. Think your variables again.

Thank you so much you two! With your advice , i figured out with some references and i did it! YES!! I feel so proud of myself! Thank you so much!!!

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.