Author Topic: Is anyone familiar with visual basic? I need help  (Read 818 times)

Offline SilverZ06

  • Silver Member
  • ****
  • Posts: 1727
Is anyone familiar with visual basic? I need help
« on: April 01, 2014, 04:42:53 PM »
I am taking an intro to visual basic using visual studio 2012 and I have a horrible instructor. He basically reads power point slides to us and that is it. No hands on work in the class room at all. I don't understand how you have a computer programming class without doing any work on computers  :headscratch:. Anyway I have a problem that is due tonight but I have until next tuesday to turn it in late. Here is the problem:








I am seriously lost as to how I am supposed to populate the array with input from text boxes. How do I determine what the user entered and where it goes? For example. Lets say a user entered a 5 of clubs. How does the program know to populate a 1 in the array "hand" in element (0,4)? I do not see any similar examples in the book or power point slides that explains this.  Hopefully someone here has some knowledge they would like to share with me. Thanks in advance.

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12425
      • http://www.hitechcreations.com
Re: Is anyone familiar with visual basic? I need help
« Reply #1 on: April 01, 2014, 08:19:07 PM »
The instructions suck. He wants you to put a 1 or 0 in the 2d array based on the user input . I would tAke A string like h11 as input the set 3,11to 1. Next you need to run test on the 2d array for flush straight 2pair ext

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12425
      • http://www.hitechcreations.com
Re: Is anyone familiar with visual basic? I need help
« Reply #2 on: April 01, 2014, 08:22:42 PM »
Tip do searches starting with hi hand first ,does you will get4kind showing as pair type problems

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12425
      • http://www.hitechcreations.com
Re: Is anyone familiar with visual basic? I need help
« Reply #3 on: April 01, 2014, 08:27:42 PM »
PS this is not a tiny program would be 1 to3 Hours to me

Offline Easyscor

  • Plutonium Member
  • *******
  • Posts: 10908
Re: Is anyone familiar with visual basic? I need help
« Reply #4 on: April 01, 2014, 10:15:51 PM »
If this is a basic Visual Basic course, are you sure he expects you to open a text box?

I ask because I don't see that in these instructions and most of the time these guys are looking for text based I/O.

I'm really rusty, ie I don't remember the reserve words anymore, and the language has been updated since the '80s ...

start: REM re-entry point
PRINT "Enter first card:"
INPUT FirstCard$
PRINT "Enter second card:"
INPUT SecondCard$
etc

CALLSUB Transfer_to_array
etc

...

GOTO start

Transfer_to_array
code
END SUB
Easy in-game again.
Since Tour 19 - 2001

Offline grizz441

  • Platinum Member
  • ******
  • Posts: 7001
Re: Is anyone familiar with visual basic? I need help
« Reply #5 on: April 01, 2014, 10:18:50 PM »
52 IF statements!  :aok

Offline SilverZ06

  • Silver Member
  • ****
  • Posts: 1727
Re: Is anyone familiar with visual basic? I need help
« Reply #6 on: April 01, 2014, 10:37:18 PM »
52 IF statements!  :aok

 :lol That is what I was trying to avoid


If this is a basic Visual Basic course, are you sure he expects you to open a text box?

I ask because I don't see that in these instructions and most of the time these guys are looking for text based I/O.

I'm really rusty, ie I don't remember the reserve words anymore, and the language has been updated since the '80s ...

start: REM re-entry point
PRINT "Enter first card:"
INPUT FirstCard$
PRINT "Enter second card:"
INPUT SecondCard$
etc

CALLSUB Transfer_to_array
etc

...

GOTO start

Transfer_to_array
code
END SUB


This is what the example in the book showed:


Apparently everyone in the class is having trouble with this program so he extended the due date 1 week without penalty. I told my instructor I was having trouble figuring out how to populate the array and asked how to do it and this was his most helpful answer..."There are many ways to do it.....People do it differently."  :bhead

Offline grizz441

  • Platinum Member
  • ******
  • Posts: 7001
Re: Is anyone familiar with visual basic? I need help
« Reply #7 on: April 01, 2014, 10:40:36 PM »
Do you get extra credit for error trapping it against the user from inputting the same value twice?

Offline SilverZ06

  • Silver Member
  • ****
  • Posts: 1727
Re: Is anyone familiar with visual basic? I need help
« Reply #8 on: April 01, 2014, 10:49:26 PM »
Do you get extra credit for error trapping it against the user from inputting the same value twice?

I don't think so. I don't think he even checks that to be honest. I think he enters a hand and just sees if the program works. If this were my "C" programming instructor I would definitely be losing points for not validating data, but this guy isn't that thorough. I wish I would have looked this instructor up before signing up for his class. I really want to learn this but just having him reading power point slides without any hands on training is not an easy way for me to learn.

Offline grizz441

  • Platinum Member
  • ******
  • Posts: 7001
Re: Is anyone familiar with visual basic? I need help
« Reply #9 on: April 01, 2014, 11:10:11 PM »
I haven't programmed since high school but I would first populate a 4x13 array with 1 (ace) through 13 (K) in each row.... for example 2 of spades will be (1,2) 2 of hearts (2,2) etc
 Then on user input, convert a jack to ace input and suit to its corresponding number. you now  have an x and y variable that you need to cross check to the array. Now retrieve (x,y) so say he enters 2 S it will pull (1,2). With these 5 array locarions put 1 into a 4x13 new array with 0s in all others fields.  Maybe that gets you in the right direction?  :headscratch:

Hitech I know what you are thinking and the answer is no I can't work for you I am already happily employed.
« Last Edit: April 01, 2014, 11:16:16 PM by grizz441 »

Offline Easyscor

  • Plutonium Member
  • *******
  • Posts: 10908
Re: Is anyone familiar with visual basic? I need help
« Reply #10 on: April 01, 2014, 11:41:19 PM »
Wait, is this another April Fools joke?

argh, Edit for correction.

Why would you DIM 3,12 when all you'd need is DIM 4,1? Zero the two values for a no card place holder.

ie

if card 2 is a 5 of spades, then 2,0 = 5 and 2,1 = spade
if card 3 hasn't been input, then 3,0 = 0 and 3,1 = 0
etc

The reverse is also acceptable, DIM 1,4 and matches the suit before the value in the original exercise. Both are 10 element arrays.

Comparisons are much more straight forward.
« Last Edit: April 02, 2014, 02:39:16 AM by Easyscor »
Easy in-game again.
Since Tour 19 - 2001

Offline Easyscor

  • Plutonium Member
  • *******
  • Posts: 10908
Re: Is anyone familiar with visual basic? I need help
« Reply #11 on: April 02, 2014, 03:23:22 AM »
DIM 4,13

A|2|3|4|5|6|7|8|9|J|Q|K| [Total in Suit]

0|0|0|0|1|0|0|0|0|0|0|0| [1]
0|0|0|0|1|0|0|0|0|0|0|0| [1]
1|0|0|0|1|0|0|0|0|0|0|0| [2]
1|0|0|0|0|0|0|0|0|0|0|0| [1]

Total count of same value cards
2|0|0|0|3|0|0|0|0|0|0|0|

Three 5's over Two Aces: Full House


Easy in-game again.
Since Tour 19 - 2001

Offline Swoop

  • Plutonium Member
  • *******
  • Posts: 9180
Re: Is anyone familiar with visual basic? I need help
« Reply #12 on: April 02, 2014, 03:50:04 AM »
Create a userform with 2 rows of drop down boxes that are pre-validated to suits / cards.

You can refer to the text value of an input box on a userform as if it was a declared variable and, therefore, run scripts to decide where in the array needs to be a 1.

eg, assuming you've already discovered the suit and assigned a numerical value to it.....

If VAL(userform1.textbox1.text) > 0 then                   'ie, if the text entry has a numerical value then it must be 2 - 10.
     array(suit, VAL(userform1.textbox1.text)-1) = 1
End If

Then you've gotta do the same for cards without a numerical value....however, you could use the ASCII value if you want to avoid lots of IF whatever = "K", etc.

« Last Edit: April 02, 2014, 03:52:07 AM by Swoop »

Offline SilverZ06

  • Silver Member
  • ****
  • Posts: 1727
Re: Is anyone familiar with visual basic? I need help
« Reply #13 on: April 02, 2014, 09:01:14 AM »
Create a userform with 2 rows of drop down boxes that are pre-validated to suits / cards.

You can refer to the text value of an input box on a userform as if it was a declared variable and, therefore, run scripts to decide where in the array needs to be a 1.

eg, assuming you've already discovered the suit and assigned a numerical value to it.....

If VAL(userform1.textbox1.text) > 0 then                   'ie, if the text entry has a numerical value then it must be 2 - 10.
     array(suit, VAL(userform1.textbox1.text)-1) = 1
End If

Then you've gotta do the same for cards without a numerical value....however, you could use the ASCII value if you want to avoid lots of IF whatever = "K", etc.



I was going to use 1 for Ace, 11 for jack, 12 for queen, and 13 for king. So that would still work. But how would I then test against the suit? I guess I need to make two single dimension arrays and then combine them to create the two dimensional array?

Offline SilverZ06

  • Silver Member
  • ****
  • Posts: 1727
Re: Is anyone familiar with visual basic? I need help
« Reply #14 on: April 02, 2014, 09:07:02 AM »
Wait, is this another April Fools joke?

argh, Edit for correction.

Why would you DIM 3,12 when all you'd need is DIM 4,1? Zero the two values for a no card place holder.

ie

if card 2 is a 5 of spades, then 2,0 = 5 and 2,1 = spade
if card 3 hasn't been input, then 3,0 = 0 and 3,1 = 0
etc

The reverse is also acceptable, DIM 1,4 and matches the suit before the value in the original exercise. Both are 10 element arrays.

Comparisons are much more straight forward.
The way I understand it in VB is a Dim array(3) is actually a 4 element array 0,1,2,3. I don't know why VB does it this way when I was taught in logic and so far in "C" that the array size is determined by the number of elements. so in "C" an array[3] would actually only contain three elements 0,1,2.