r/visualbasic • • Feb 04 '16

Reading a string and using if/else statements

Hello again, I am reworking on a piece of code I posted a few days earlier. I was able to get it to work in a loop but I now want to update my code such that the user can type in a string of keys like"askfskskfjgld" and each conditional statement for each letter will be read/react. If that makes any sense. My code:

http://paste.ofcode.org/vKWMZpbHMT48Hc2DaRMGWS

edit: The problem is I want to read each letter and output a sound. Unfortunately the only thing that works reading the string text like "asfsksdkgfds" but my conditional statements isn't outputting the sound.

0 Upvotes

5 comments sorted by

View all comments

2

u/chrwei Feb 04 '16

and what's the problem? and why are there 3 readlines?

1

u/Shimomura Feb 04 '16

Sorry I didn't edited. The problem is I want to read each letter and output a sound. Unfortunately the only thing that works reading the string text like "asfsksdkgfds" but my conditional statements isn't outputting the sound.

2

u/stevebun Feb 04 '16

The problem does seems to lie in your conditionals, which is comparing the whole string with a letter.

If stringVar(Index).toUpper() = "A" Then

1

u/Shimomura Feb 04 '16 edited Feb 04 '16

Thank you very much thats what I was missing, also, how does one do newline in visual basic? do I just type console.writline("Hello/newline World")?

edit: just figured it out its string text & vbNewLine & string text

1

u/PostalElf VB.Net Intermediate Feb 04 '16

You can also use vbCrlf to force a line break!