Calgarypuck Forums - The Unofficial Calgary Flames Fan Community

Go Back   Calgarypuck Forums - The Unofficial Calgary Flames Fan Community > Main Forums > The Off Topic Forum > Tech Talk
Register Forum Rules FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread
Old 10-14-2010, 03:40 PM   #1
iggyntangs
Scoring Winger
 
iggyntangs's Avatar
 
Join Date: Oct 2010
Exp:
Default VBA Excel

Anybody know how to make any decent games or interesting programs via Visual Basic coding in Excel?

I have a group proj in VBA Programming at school, and I'm not very good, could use help!
iggyntangs is offline   Reply With Quote
Old 10-14-2010, 03:50 PM   #2
Komskies
Franchise Player
 
Komskies's Avatar
 
Join Date: Mar 2009
Location: Calgary
Exp:
Default

U of C?
Komskies is offline   Reply With Quote
Old 10-14-2010, 04:05 PM   #3
iggyntangs
Scoring Winger
 
iggyntangs's Avatar
 
Join Date: Oct 2010
Exp:
Default

Yeap.
iggyntangs is offline   Reply With Quote
Old 10-14-2010, 06:08 PM   #4
Bob
Franchise Player
 
Join Date: Jan 2007
Exp:
Default

Programming *in* Excel?

Well, there was that one dude who did basic 3D graphics ...



Beyond that it's a pretty limited environment I think, though you probably could write a Tetris clone using the cells as the game grid.
Bob is offline   Reply With Quote
Old 10-14-2010, 11:58 PM   #5
iggyntangs
Scoring Winger
 
iggyntangs's Avatar
 
Join Date: Oct 2010
Exp:
Default

Interesting.

I was thinking perhaps Battleships? Know if this could be done?
iggyntangs is offline   Reply With Quote
Old 10-15-2010, 12:04 AM   #6
Bob
Franchise Player
 
Join Date: Jan 2007
Exp:
Default

Battleship? Sure, that can be done. That's probably quite a bit easier than Tetris.
Bob is offline   Reply With Quote
Old 10-15-2010, 12:16 AM   #7
iggyntangs
Scoring Winger
 
iggyntangs's Avatar
 
Join Date: Oct 2010
Exp:
Default

I'll look into it, just a n00b at VB coding which is why I started up this thread.
iggyntangs is offline   Reply With Quote
Old 10-15-2010, 07:36 AM   #8
Komskies
Franchise Player
 
Komskies's Avatar
 
Join Date: Mar 2009
Location: Calgary
Exp:
Default

Is Cam Welsh your prof for this VBA class?
Komskies is offline   Reply With Quote
Old 10-15-2010, 09:20 AM   #9
yads
Powerplay Quarterback
 
Join Date: Apr 2008
Exp:
Default

Is the assignment to program a game in Excel? If it is, it doesn't necessarily need to have graphics. You can code up a board game in it. I know I've seen Puerto Rico in Excel.
yads is offline   Reply With Quote
Old 10-15-2010, 04:38 PM   #10
iggyntangs
Scoring Winger
 
iggyntangs's Avatar
 
Join Date: Oct 2010
Exp:
Default

Quote:
Originally Posted by Komskies View Post
Is Cam Welsh your prof for this VBA class?
Haha yeap!
iggyntangs is offline   Reply With Quote
Old 10-15-2010, 04:39 PM   #11
iggyntangs
Scoring Winger
 
iggyntangs's Avatar
 
Join Date: Oct 2010
Exp:
Default

Quote:
Originally Posted by yads View Post
Is the assignment to program a game in Excel? If it is, it doesn't necessarily need to have graphics. You can code up a board game in it. I know I've seen Puerto Rico in Excel.
No need for graphics whatsoever.
iggyntangs is offline   Reply With Quote
Old 10-15-2010, 04:56 PM   #12
Komskies
Franchise Player
 
Komskies's Avatar
 
Join Date: Mar 2009
Location: Calgary
Exp:
Default

I took that very class a few years ago. OPMA 413 if I remember correctly. Let me see if I can locate my project. We made a hockey pool that pulled stats through a web query. It was pretty simple, but we had solid code and it looked nice so we ended up getting a good mark.

Feel free to go to Cam for ideas and help. He was one of the best instructors I had at U of C.
Komskies is offline   Reply With Quote
Old 10-15-2010, 05:05 PM   #13
iggyntangs
Scoring Winger
 
iggyntangs's Avatar
 
Join Date: Oct 2010
Exp:
Default

Quote:
Originally Posted by Komskies View Post
I took that very class a few years ago. OPMA 413 if I remember correctly. Let me see if I can locate my project. We made a hockey pool that pulled stats through a web query. It was pretty simple, but we had solid code and it looked nice so we ended up getting a good mark.

Feel free to go to Cam for ideas and help. He was one of the best instructors I had at U of C.
That'd be great to see.

And yeah he's very approachable and helpful for sure.
iggyntangs is offline   Reply With Quote
Old 10-15-2010, 06:17 PM   #14
flamesrule_kipper34
Franchise Player
 
flamesrule_kipper34's Avatar
 
Join Date: Aug 2008
Location: Calgary, AB
Exp:
Default

I'm attempting to make a code for the following situation: "Write a subroutine that requests the user to enter a negative even integer using an input box. The subroutine needs to sum all the even integers between one hundred and twenty-one (121) and the inputted number and display the result in a message box. Your message box must let the user know what they are seeing and must include the number entered into the input box as part of the message. This routine must Include error checking that validates the initial inputted number as negative, as odd, and as an integer. You may not use the spreadsheet to accomplish any aspect of the task except to hold the form control button that invokes the subroutine."

Here's what I have so far:

Sub enternumber()
Dim mynum As Integer, Sum As Double, i As Double, isValid As Boolean
mynum = InputBox("Please enter a negative even integer")
Do Until isValid = True
If mynum >= 0 Then
MsgBox ("Please enter a negative even integer")
isValid = False
mynum = InputBox("Please enter a negative even integer")
Else
isValid = True
End If
Loop
Sum = 0

For i = mynum + 1 To 0 Step 2
Sum = Sum + i
Next
MsgBox ("The sum is " & Sum)
End Sub

Last edited by flamesrule_kipper34; 10-15-2010 at 06:44 PM.
flamesrule_kipper34 is offline   Reply With Quote
Old 10-15-2010, 06:45 PM   #15
flamesrule_kipper34
Franchise Player
 
flamesrule_kipper34's Avatar
 
Join Date: Aug 2008
Location: Calgary, AB
Exp:
Default

The thing is the above sum's the inputted number to 0 and not what I want, I need help with the math input into the code...
flamesrule_kipper34 is offline   Reply With Quote
Old 10-16-2010, 11:50 AM   #16
username
Powerplay Quarterback
 
username's Avatar
 
Join Date: Feb 2010
Exp:
Default

Well first off - you should divide the inputted number by 2 and check to see that it's even. If there's a remainder then you know it's an odd number. This will also guarantee it's an integer since there will be no precision. Then make it another error check on it's own. You should display error messages for the error they are for.

second - In your second loop, don't inc by 2, do it by one and just divide by 2. If there's a remainder then don't add the number to sum. Once you're out of you second loop, add sum to my num and display them.
username is offline   Reply With Quote
Old 10-16-2010, 11:53 AM   #17
Sparks
Scoring Winger
 
Sparks's Avatar
 
Join Date: Dec 2005
Location: Brisbane, Australia
Exp:
Default

^^ Here's my best guess.

Your program doesn't check to see if the integer entered is odd or not, only if it's negative. That might lose you some marks. The way the question is worded is also kind of hard to understand. If I've got it right, it wants you to sum all of the even integers between the (odd, negative) number entered and 121?

I'm not sure how this language works but it seems to me that if you want to do it the way you're doing it, all you want to do is change the for loop to:

For i = mynum + 1 To 121 Step 2

Also, why are sum and i double? They're both always going to be integers. Sum could potentially be a big number, though, so you might want to use a different type (like long) if that exists.

Last edited by Sparks; 10-16-2010 at 12:04 PM.
Sparks is offline   Reply With Quote
Old 10-16-2010, 02:24 PM   #18
Bob
Franchise Player
 
Join Date: Jan 2007
Exp:
Default

The description says to sum all *even* numbers from 121 to your number (a negative, even integer), so you've got it backwards.

Quote:
The subroutine needs to sum all the even integers between one hundred and twenty-one (121) and the inputted number and display the result in a message box.
Code:
For i = 120 To mynum Step -2
I don't see the point of starting at 121 if we're using even numbers all the way. It's also fine to start at mynum and go up to 121, but assignments like this are known for their pedantry. It's probably safer (from an academic perspective) to check the starting number and adjust it down if it's odd so it doesn't break your loop. Something like:

Code:
Start = 121
If Start Mod 2 <> 0 Then
Start = Start - 1
End If

For i = Start To mynum Step -2
...
The argument being "your code doesn't work if I give you a different starting number, or ask the user for a starting number", etc. I always encountered silly technicalities like that.

There's no need to add 1 to mynum to start the loop if you've already verified that a) it's negative, and b) it's even. You've already got negative numbers, so you should be able to modify your data entry check to account for non even numbers. I don't know if this is syntactically correct, but you need the modulus operator.

Code:
If mynum >= 0 Or mynum Mod 2 <> 0 Then
Essentially, reject the input if it's a) non-negative or b) the remainder when dividing by two is non-zero (i.e. it's an odd number).

Last edited by Bob; 10-16-2010 at 02:29 PM.
Bob is offline   Reply With Quote
The Following User Says Thank You to Bob For This Useful Post:
Old 10-16-2010, 02:46 PM   #19
Sparks
Scoring Winger
 
Sparks's Avatar
 
Join Date: Dec 2005
Location: Brisbane, Australia
Exp:
Default

Quote:
Originally Posted by Bob View Post
The description says to sum all *even* numbers from 121 to your number (a negative, even integer), so you've got it backwards.
He might not have it backwards - the description actually says both!

Quote:
Write a subroutine that requests the user to enter a negative even integer using an input box.
Quote:
This routine must Include error checking that validates the initial inputted number as negative, as odd, and as an integer.
Confusing to say the least.
Sparks is offline   Reply With Quote
Old 10-16-2010, 02:51 PM   #20
Bob
Franchise Player
 
Join Date: Jan 2007
Exp:
Default

Quote:
Originally Posted by Sparks View Post
He might not have it backwards - the description actually says both!



Confusing to say the least.
Wow, that's quite the mistake.

Well, maybe he's subtlety preparing the students for contradictory specs in actual projects. Reminds me of this comic:

Bob is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 10:18 AM.

Calgary Flames
2023-24




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Calgarypuck 2021