PDA

View Full Version : I need help with visual basic fast......



adizlaja
January 14th, 2002, 18:03
Hello all,

I'm trying to make a vb application but I ran into some trouble.

I'm trying to make a simple application that has two labels stacked under one another and two buttons besides the labels that say "Start" and "Done." The top label will only have instructions in it, so it's no big deal but the 2nd label, which would be underneath the first label, should display the answer which I'm about to explain.

When the user clicks "Start" on the application, it should pop up 5 Input boxed one after another asking the user how many visitors they recieve each day on their website. When the first input box pops up the user types in the number of visitors he got that day, then after he pushed "OK" another input box pops up and asks him the same question again. This goes on for five input boxed, asking the user for the visitor for 5 days of visitors that came to their site. When the user is done with putting in all the information, and hits "OK" for the last time, it should give him the average number of hits that he recieves for each day out of the five days that he entered. This answer should be displayed in the lower label.

Now, here is the code that I tried to use to make this application work, but I'm 100% that I messed up alot so I'm asking some of you to modify it and if possible make my application work. Here goes my code:
-------------------------------------------------------------------------------
Option Explicit
_________________________
Private Sub cmdStart_Click()
Dim int1 As Integer, int2 As Integer, int3 As Integer, int4 As Integer, int5 As Integer, int6 As Integer
Dim intC As Integer
Const intD As Integer = 5

lblAverage.Caption = ""
Do
Loop While int4 = InputBox("Enter Average Daily Attendence", "Attendence")
int1 = int1 + int4
Do
Loop While int3 = InputBox("Enter Average Daily Attendence", "Attendence")
int1 = int1 + int3
Do
Loop While int2 = InputBox("Enter Average Daily Attendence", "Attendence")
int1 = int1 + int2
Do
Loop While int5 = InputBox("Enter Average Daily Attendence", "Attendence")
int1 = int1 + int5
Do
Loop While int6 = InputBox("Enter Average Daily Attendence", "Attendence")
int1 = int1 + int6
lblAverage = int4 + int3 + int2 + int5 + int6 / intD
End Sub
_________________________
Private Sub cmdDone_click()
Unload Me
End Sub
_________________________
-------------------------------------------------------------------------------
OK, that would be the code that I have for right now. It's not totally done, because I'm stuck and it looks totally wrong. If I'm using a wrong method please correct me.

I will appriciate all the help that I can get ;)

Pedroz
January 14th, 2002, 18:58
---------------------------------------
Private Sub cmdStart_Click()

Dim int1 As Integer
Dim a As Integer
Dim intC As Integer


lblAverage.Caption = ""

For a = 1 To 5
int1 = InputBox("Enter Average Daily Attendence", "Attendence")
intC = intC + int1
Next a

lblAverage.Caption = intC / 5

End Sub
----------------------------------------

Happy programming!

adizlaja
January 14th, 2002, 19:23
Wait, is that it? Will that make the whole program work or do I have to repeat that step multiple times? I don't have vB on this PC so I can't test it at the moment. If possible, could someone maybe make the application and upload it on the web so that I can test it?

Thank you ver much.... :)

Bruce
January 14th, 2002, 20:03
I just whipped this up in about 3 minutes. It works, but you may need to customize it a bit.

http://members.bellatlantic.net/~vze2tkr8/attendance.tar.gz (3k)

adizlaja
January 14th, 2002, 20:17
Thanx Phrozen and Pedroz for helping with this bugger :rolleyes: