Adventure Game Studio

Community => General Discussion => Topic started by: InCreator on Fri 30/12/2011 17:40:07

Title: Need quick Excel/VBA scripting help
Post by: InCreator on Fri 30/12/2011 17:40:07
(http://i.imgur.com/P1xnr.png)

Thing is like this. There's a a sports event. Marathon or track run or whatever.
Every contestant has name (or number, as on picture) and amount of laps done under corresponding column.

What I want to do is that every time contestant finishes a lap, you can just type his number somewhere (say, a query window opens where you can enter his number or whatever) and automatically "laps" count under correct contestant number will increase.

The list of contestants could be very long so it would be too time consuming to find correct contestant by hand every time lap is finished, that's why this system should work in such quicker way. I know it's basically "hello world" in any other programming language, but I'm not too familiar with scripting in VBA and no time to learn it enough to be. And they demand it'd work in excel.

Can anyone help?
Title: Re: Need quick Excel/VBA scripting help
Post by: HandsFree on Sat 31/12/2011 15:58:26
I'm no way an expert but this should be possible (I tried it a bit and I could at least update a cell using input commands).
If you're going to really use it during a sports event it has to be very robust though.
When do you need this?
Title: Re: Need quick Excel/VBA scripting help
Post by: InCreator on Tue 03/01/2012 06:22:02
Well, after few hours, I managed to make this myself with few lines of code. VBA is quite terrible compared to other programming languages (I honestly didn't remember such loose syntax and downright absurd mathematical operations from QBasic days... a = a+1, seriously?), but eventually I got what I needed.
Title: Re: Need quick Excel/VBA scripting help
Post by: SSH on Tue 03/01/2012 08:18:56
You could just enter the contestant number in a big long column every time they pass the start (one row each time a new contestant passes) and then use =COUNTIF(B:B, <contestant no>)

Title: Re: Need quick Excel/VBA scripting help
Post by: Khris on Tue 03/01/2012 11:02:33
Quote from: InCreator on Tue 03/01/2012 06:22:02a = a+1

What's wrong with that? Isn't that how pretty much every other language does it, too?
Title: Re: Need quick Excel/VBA scripting help
Post by: Calin Leafshade on Tue 03/01/2012 13:25:46
a = a + 1 is perfectly valid syntax in pretty much every language i know of.

Remember that the = sign is *not* an equals sign. It is the assignment operator.

In fact older BASIC style languages use the keyword LET which is a more mathematical way of writing it.
Title: Re: Need quick Excel/VBA scripting help
Post by: Radiant on Tue 03/01/2012 16:59:59
Quote from: Calin Leafshade on Tue 03/01/2012 13:25:46
a = a + 1 is perfectly valid syntax in pretty much every language i know of.

The entire C family of languages (which includes Java, PHP, and AGS) uses = for assignment and == for comparison. Pascal uses : = for assignment and = for comparison. BASIC is confusing in that it uses = for both.

At any rate, yes, this is one reason why math majors tend not to like CS majors. Another is that CS grads make much more money :P