Jump to content

Need help in Visual Basic

Rayhaan Jiwani

Hello Forum,

 

The title doesn't actually describe my issue but I wanted someone to give me a few practice questions in Visual Basic as my exams are approaching. I don't care if it's like 'If the number is greater than 1, then end loop' or something like that because we haven't learnt too much anyways, but could someone frame a few questions with: Do While Loop, Do Until Loop, For Next Loop and Select Case

The main goal of this is just to see whether I remember the syntax and can do simple looping programs. And toss me a brief (and easy) explanation of the Select Case thing. I tried MSDN but it's too complicated.

 

Thanks! :)

CPU: i5 4690K @ Stock                GPU: Asus GTX 970 STRIX @ Stock      SSD: Samsung 850 EVO 120GB (OS and Drivers)     Headset: Audio-Technica M20X

Case: Corsair Obsidian 250D        RAM: Kingston HyperX 16GB LP             HDD: WD Caviar Black 2TB                                         Mouse: Logitech m185

OS: Windows 8.1 OEM                 PSU: Corsair RM650                                Motherboard: Gigabyte Z97N Mini ITX                         Keyboard: Corsair Gaming K65 RGB

Link to comment
Share on other sites

Link to post
Share on other sites

And toss me a brief (and easy) explanation of the Select Case thing. I tried MSDN but it's too complicated.

 

Thanks! :)

Youtube is your friend in this case, it was a big help when i learned c#(already forgotten most of it unfortunately :D ).
Link to comment
Share on other sites

Link to post
Share on other sites

1. Given two integers from user input, add up all the odd numbers between the two values (include the chosen values as well) and output the result. Example output

Enter two integers: 2 10The sum of odd numbers between 2 and 10 (inclusive) is 24.Enter two integers: 3 3The sum of odd numbers between 3 and 3 (inclusive) is 3.Enter two integers: 25 23The sum of odd numbers between 23 and 25 (inclusive) is 48.

2. Given a letter and the name of a text file from user input, count how many times that letter appears in the file, ignoring case (if you're looking for 'H', both 'h' and 'H' would increase count). Example: (assume helloworld.txt just contains the words "hello world")

Enter filename: helloworld.txtEnter letter: oThe letter 'o' appears 2 times.Enter filename: helloworld.txtEnter letter: xThe letter 'x' appears 0 times.Enter filename: helloworld.txtEnter letter: EThe letter 'E' appears 1 time.

If you haven't learned to work with text files, get a String instead.

Enter string: Hello worldEnter letter: hThe letter 'h' appears 1 time.

3. Given an array of card values [2,3,4,5,6,7,8,9,10,J,Q,K,A], get 2 cards from user input and output the larger of the two or output that they are the same. Examples

Pick two cards: A 4A is the better card.Pick two cards: J JBoth cards are the same.Pick two cards: Q KK is the better card.

4. Generate a random number between 1 and 100 (inclusive). Guess the number though user input until you win. If the guess is wrong, tell them if they are higher or lower. If they are right, tell them they win. Example (assume secret number is 33)

What is your guess? 50Too high.What is your guess? 40Too high.What is your guess? 30Too low.What is your guess? 33Correct.
Link to comment
Share on other sites

Link to post
Share on other sites

I suggest doing past Canadian Computing Competition questions. They're not necessarily hard (especially if you go for the first couple J questions), but they do make you think and can even be very challenging (especially the last couple S questions).

 

https://cemc.math.uwaterloo.ca/contests/past_contests.html#ccc

15" MBP TB

AMD 5800X | Gigabyte Aorus Master | EVGA 2060 KO Ultra | Define 7 || Blade Server: Intel 3570k | GD65 | Corsair C70 | 13TB

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×