6 Replies - 2267 Views - Last Post: 13 March 2013 - 09:13 PM Rate Topic: -----

#1 Cronos35  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 10-March 13

outputting a random word on a label (vb6 typing game)

Posted 10 March 2013 - 10:49 PM

Good day all!!

I'm a college student and we've been given the task of making any vb6 game as a project.

I've decided that i'd make a simple typing game where words would pop out of a label for a few seconds (limited by a timer) and then after a few seconds another word would pop out of the label and would repeat for, say, 32 times.

I already got the logic of my project, the problem is that i don't know what function to use in outputting a random word. I know that it's got something to do with select case, where the words that would appear on the label would be listed and that my program would have to randomly pick out a word from that list of words. I've come across the random string function although i have no idea how to use it.

Anyone know of a function i could use for this exact purpose?

Is This A Good Question/Topic? 0
  • +

Replies To: outputting a random word on a label (vb6 typing game)

#2 Takk  Icon User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 111
  • Joined: 08-March 13

Re: outputting a random word on a label (vb6 typing game)

Posted 11 March 2013 - 12:04 AM

It really depends on the words you want to output, if you are happy having the user type something like XssfErT, as opposed to the word Dollar, Mansion, etc...

either way, you will need to generate at least one random number. (Rnd() function)

first method you would start with a string such as 'abcdefgh-------' and just pick how ever many random letters with the mid() function and combine them into a string which you display on the label

the second method, you would need to load or code a list of pre-determined words into an array and use the random number to select a specific index, and display that elements word on the label. myarray(randomnumber) would return a random word.

I wouldn't call either these a function you could use for this exact purpose, but this is generally all you will have to work with in this case.


If you're feeling sporty in your abilities with vb6, look into the BitBlt API ;) The football players who took programming because art was full tried to get me in trouble for flying my space ship around the screen.
Was This Post Helpful? 0
  • +
  • -

#3 Cronos35  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 10-March 13

Re: outputting a random word on a label (vb6 typing game)

Posted 12 March 2013 - 03:48 AM

could you show me an example of both methods? i'm not quite familiar with arrays yet. we haven't covered them in our lessons yet (and the school year is about to end) and i haven't been doing my research xD
Was This Post Helpful? 0
  • +
  • -

#4 Takk  Icon User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 111
  • Joined: 08-March 13

Re: outputting a random word on a label (vb6 typing game)

Posted 12 March 2013 - 08:17 AM

Google is your best option if you weren't really trying to take anything away from this experience bro. I'd be happy to nudge you along the correct path if you had a specific question, but we can't do the work for you.
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: outputting a random word on a label (vb6 typing game)

Posted 12 March 2013 - 09:26 PM

Set up an array of words. Then output a random integer from zero to the upper bound of your array. That will be the word that you're looking for. If you want to avoid repeating, that's another step. Solve step 1 and we'll talk about it.
Was This Post Helpful? 0
  • +
  • -

#6 Cronos35  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 10-March 13

Re: outputting a random word on a label (vb6 typing game)

Posted 12 March 2013 - 10:57 PM

ok here, how do i use Array to do that? the Array method seems to the kind of abilities i need for the job so i'd like to know how i could use that, especially the randomizing of words.
Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: outputting a random word on a label (vb6 typing game)

Posted 13 March 2013 - 09:13 PM

You'll want to read up on arrays and on the rnd function. I have a post pinned up top that tells you where the VB6 reference materials are. Once you've made a good faith attempt on your own, we'll help you if you get stuck.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1