Ok Im having a hell of a time figuring out Assignment 2 in CMPT 110. Text book is a useless, study guide is useless. Totally lost. Have no idea how to program in Visual Basic. Anyone done it, or can help me with it?
I'm very new to VB, no programming experience at all. yes it is CMPT 110
assignment asks to make a button "abcde" and another button "next" when button "abcde" is pressed "a" is displayed in text box (read only). when "next" button is clicked the next letter "b" is displayed, then "c" and so on. I have to make another button that changes the letter case. ex. when button "case" is clicked the letter displayed in text box ("a") should change to ("A"). Another button to delete the previous letter on the screen (and im assuming display the previous letter). Another button to exit the program. -_- thanks!
forgot to mention, no "if statements" allowed. and suppose to use something called "shared" variable. and use the ASCII codes to scroll through the letters.
Ok, I haven't used VB in a long time. I don't even have it on this computer. I don't even have windows on this computer, so these functions probably don't even exist, but here's how I would do it.
Your "abcde" button - open up the "action performed" code for it. Then, in that code, do something like
textbox1.setText(\"a\").
Now, the "next" button - go to its "action performed" section - the action should access the the letter in the textbox and add 1 to it because ascii letters are ordered by number, each being 1 greater than the last.
textbox1.setText( textbox1.charAt(0) + 1 )
For the shift button, do the same as "next" but subtract 35 instead of adding 1. The upper case letters are 35 less than their lowercase equivalents in ascii.
edit: there, see? I can be helpful, even if it is VB. I didn't even mock the OP once.
Ok, I haven't used VB in a long time. I don't even have it on this computer. I don't even have windows on this computer, so these functions probably don't even exist, but here's how I would do it.
Your "abcde" button - open up the "action performed" code for it. Then, in that code, do something like
textbox1.setText(\"a\").
Now, the "next" button - go to its "action performed" section - the action should access the the letter in the textbox and add 1 to it because ascii letters are ordered by number, each being 1 greater than the last.
textbox1.setText( textbox1.charAt(0) + 1 )
For the shift button, do the same as "next" but subtract 35 instead of adding 1. The upper case letters are 35 less than their lowercase equivalents in ascii.
edit: there, see? I can be helpful, even if it is VB. I didn't even mock the OP once.
error : "setText is not a member of system.windows.Forms.... " are you sure your talking in VB terms?
mod, or "%" in most languages just gives you the remainder of a division.
ie: 3 mod 2 = 1
prof says so.. lol have to use MOD 5 or something to find the displacement of the "ascii" general equation and use "chr" command to display command in textbox his ex. is: displacement = (displacement + 1) Mod 5
Here's how to loop through letters for a while with the mod operator. (I still think this is a weird thing to do.. but ooookaaay)
Suppose you have a 5 letter cycle: A B C D E
also, suppose that A=0, B=1 C=2 D=3 E=4
and your counter variable X
Set X = 0
now, for every time the "next" button is clicked:
increment X by one display the character that corresponds to X mod 5
0 mod 5 = 0 A 1 mod 5 = 1 B 2 mod 5 = 2 C 3 mod 5 = 3 D 4 mod 5 = 4 E 5 mod 5 = 0 A 6 mod 5 = 1 B 7 mod 5 = 2 C
see how the pattern repeats itself? Anyways, that's probably what your prof wants you to do to the letters. There are some more details you'll need to work out if you're doing it with ascii because ascii values are actually like 90-120 or something like that.
That's the general idea. Now go figure the rest out yourself.
I did set up the MOD 5 and it is recognizing it to display the thing I want, but I have one more question. I need something in the code to read each displacement line with each click of the button, what it does now, is just reads all the lines at once and displays the last character "E", how do I do this?
Comments
You are having problems with Visual Basic.
You sir, are an epic fail.
what's the assignment?
assignment asks to make a button "abcde" and another button "next" when button "abcde" is pressed "a" is displayed in text box (read only). when "next" button is clicked the next letter "b" is displayed, then "c" and so on. I have to make another button that changes the letter case. ex. when button "case" is clicked the letter displayed in text box ("a") should change to ("A"). Another button to delete the previous letter on the screen (and im assuming display the previous letter). Another button to exit the program. -_-
thanks!
dear God!
Your "abcde" button - open up the "action performed" code for it. Then, in that code, do something like
Now, the "next" button - go to its "action performed" section - the action should access the the letter in the textbox and add 1 to it because ascii letters are ordered by number, each being 1 greater than the last.
For the shift button, do the same as "next" but subtract 35 instead of adding 1. The upper case letters are 35 less than their lowercase equivalents in ascii.
edit: there, see? I can be helpful, even if it is VB. I didn't even mock the OP once.
are you sure your talking in VB terms?
but your ascii help makes sense.
thanks
Translate it into VB.
I can't remember the exact class structure of VB's objects.
Take your book (or use google) and look at what has been taught to you and apply it to this problem.
how do u do that?
mod, or "%" in most languages just gives you the remainder of a division.
ie: 3 mod 2 = 1
have to use MOD 5 or something to find the displacement of the "ascii" general equation and use "chr" command to display command in textbox
his ex. is:
displacement = (displacement + 1) Mod 5
(I still think this is a weird thing to do.. but ooookaaay)
Suppose you have a 5 letter cycle: A B C D E
also, suppose that A=0, B=1 C=2 D=3 E=4
and your counter variable X
Set X = 0
now, for every time the "next" button is clicked:
increment X by one
display the character that corresponds to X mod 5
0 mod 5 = 0 A
1 mod 5 = 1 B
2 mod 5 = 2 C
3 mod 5 = 3 D
4 mod 5 = 4 E
5 mod 5 = 0 A
6 mod 5 = 1 B
7 mod 5 = 2 C
see how the pattern repeats itself? Anyways, that's probably what your prof wants you to do to the letters. There are some more details you'll need to work out if you're doing it with ascii because ascii values are actually like 90-120 or something like that.
That's the general idea. Now go figure the rest out yourself.
I get it now and thank you for your help!
I did set up the MOD 5 and it is recognizing it to display the thing I want, but I have one more question. I need something in the code to read each displacement line with each click of the button, what it does now, is just reads all the lines at once and displays the last character "E", how do I do this?