grrr!! I hate computer science! Why did I even bothered to take it?! It's ruining my damn average! My perfect A!! Grrr-- anyway!

I'm such a newbie in computer science, so I don't know anything.

Okay, please take a looky at this-- see if there's anything wrong with it-- I'm trying to make the listbox appear in the following picture:

(This is my teacher's exe program, similiar to mines)

[IMG]http://www.geocities.com/chopaface/teacher.jpg[/IMG]

(This my mines -__-;; it's suppose to look like my teacher's example....!!! but it's not showing the thing-- and instead of 11 it's 12!!! OMG... why is it adding? the coding doesn't say ADD... -__-;; >__>;; or does it??)

[IMG]http://www.geocities.com/chopaface/mind.jpg[/IMG]


down below is my code--

i don't care if you take it or not-- because really, i suck alot-- and this isn't even worth shit-- lol

'Wendy Quon
'December 19, 2005

Option Explicit

Private Sub cmdAllF_Click()

Dim findN As Integer

Dim i As Integer 'counter variable

Dim total As Double 'the factorial of N


findN = Val(txtn.Text)

total = 1


lstBox.Clear 'clears the listbox


If findN >= 1 And findN <= 170 Then 'verify valid input

For i = 1 To findN

total = total * i

Next i

lstBox.AddItem "The value of " & i & "! = " & Val(total)

lstcountlist.Caption = lstBox.ListCount

Else 'if input is invalid, then a message box will appear to tell the user

MsgBox ("Enter a positive number between 1 and 170 please!") 'a message box will appear


txtn.Text = "" 'clears the textbox

txtn1.Text = "" 'clears the textbox

txtn.SetFocus 'Puts back the focus to txtn

End If


End Sub

Private Sub cmdClear_Click()
lstBox.Clear
txtn.Text = ""
txtn1.Text = ""

txtn.SetFocus
End Sub

Private Sub cmdDone_Click()
End 'Unloads the program
End Sub

Private Sub cmdFactorial_Click()

Dim findN As Integer 'declare user input variable type

Dim total As Double 'the factorial of N

Dim i As Integer 'counter variables


findN = Val(txtn.Text)

total = 1


If findN >= 1 And findN <= 170 Then 'verify valid input

For i = 1 To findN

total = total * i

Next i


txtn1.Text = "The total is: " & Val(total) 'display the factorial in the second text box

Else 'if input is invalid, then a message box will appear to tell the user

MsgBox ("Enter a positive number between 0 and 170 please!") 'a message box will appear


txtn.Text = "" 'clears the textbox

txtn1.Text = "" 'clears the textbox

txtn.SetFocus 'Puts back the focus to txtn

End If

End Sub

Private Sub txtn_GotFocus()
txtn.Text = "" 'when you click this textbar, it automatically cleans the written text in the box
End Sub

SOMEONE PLEASE HELP ME T^T! lol... XD ...

but this is weird-- and .. -__-;; annoying... grrr!! lol XD

btw-- that box is a listbox-- so.. im not so sure how to insert them in.. without making multiple code lines for it o_O;; i dunno... >__<;; I don't know anymore-- damnit-- frick, computer science is a total piss off-- and im not a math person either-- im an artist-- i should have sticked to computer graphics!! damn, i learnt my lesson.. and this lesson will take the whole friggin semester for me to be punished by o_O;; .. crapp!! my life is ruined DX

You're not adding anything to your listbox except the last number in the findN.

' >>>>>>>>Try this<<<<<<<<<<

If findN >= 1 And findN <= 170 Then 'verify valid input
For i = 1 To findN
total = total * i
lstBox.AddItem "The value of " & i & "! = " & Val(total)
Next i
txtn1.Text = "The total is: " & Val(total) 'display the factorial in the second text box
Else 'if input is invalid, then a message box will appear to tell the user
MsgBox ("Enter a positive number between 1 and 170 please!") 'a message box will appear
txtn.Text = "" 'clears the textbox
txtn1.Text = "" 'clears the textbox
txtn.SetFocus 'Puts back the focus to txtn
End If

lstcountlist.Caption = lstBox.ListCount

Exit Sub
' -------------------

Basically adding items INSIDE the For/Next statement

Also you can put the ListCount before the Exit Sub statement, there is no reason to include it inside the For/Next (that would make the same caption findN times), when it remains the same.

This should work fine.

aka Kegtapper

You're not adding anything to your listbox except the last number in the findN.

' >>>>>>>>Try this<<<<<<<<<<

If findN >= 1 And findN <= 170 Then 'verify valid input
For i = 1 To findN
total = total * i
lstBox.AddItem "The value of " & i & "! = " & Val(total)
Next i
txtn1.Text = "The total is: " & Val(total) 'display the factorial in the second text box
Else 'if input is invalid, then a message box will appear to tell the user
MsgBox ("Enter a positive number between 1 and 170 please!") 'a message box will appear
txtn.Text = "" 'clears the textbox
txtn1.Text = "" 'clears the textbox
txtn.SetFocus 'Puts back the focus to txtn
End If

lstcountlist.Caption = lstBox.ListCount

Exit Sub
' -------------------

Basically adding items INSIDE the For/Next statement

Also you can put the ListCount before the Exit Sub statement, there is no reason to include it inside the For/Next (that would make the same caption findN times), when it remains the same.

This should work fine.

aka Kegtapper

CLOSED

This article has been dead for over six months. Start a new discussion instead.