Wednesday, October 29, 2008
Thurs, Oct. 30: Yet more work with menus
Today, before you begin work on your projects, I would like to be able to extend the reach of your menus. So, without any further ado --not that there was any previous ado-- let's open up the "Menus" project we made the other day, and add two controls to it.
The first control is called an "OpenFileDialog"; just drag it onto the bottom of your "Menus" form, next to the menustrip you placed there the other day. In its properties sheet, rename it "OpenSaysMe"
The other control is a "SaveFileDialog" --yup, Microsoft went all out making creative names for these controls -- drag it next to the OpenFileDialog, and rename it "SaveIt"
Once you've done that, you will want to get into the code to Open files by doubleclicking on the Open command in your menu list. Then, add in this code:
'THIS IS WHERE WE OPEN A FILE AND PUT THE STUFF INTO OUR TEXTBOX
'OpenSaysMe is the name of the FileOpenDialog
OpenSaysMe.Title = "Go Get 'em!"
'start inside the folder for your project
OpenSaysMe.InitialDirectory = saveFolder
OpenSaysMe.ShowDialog() 'open up the control to browse for files
Dim theFileIwant As String
theFileIwant = OpenSaysMe.FileName
'set the string to whatever file you chose
'make a filereader that will use the file you chose
Dim objReader As New StreamReader(theFileIwant)
MyWords.Text = objReader.ReadToEnd 'put the text of file into textbox
objReader.Close() 'stop reading
OK, once you've done that, make sure you save your work, then run the program to make sure you can actually use this to use the "Open" menu command to open up files and then put their contents into a textbox. Please be careful to open up only files with actual, words in them!
Cheers,
Mr. L
PS, If you run into any difficulties, the first thing I would look at would be the Import statement at the top of your code. If need be, please add this import line:
Imports System.IO
PPS There will be another post soon which coughs up the code for maiking the Save menu work too; be looking for it!
Sunday, October 26, 2008
Mon October 27: More fun with menus, more work on your projects!
Today, we will do three things; but only after you make a small teeny change to your menu codes (I will let you know what it is):
A) Each of you will make a group discussion posting consisting of at least one paragraph of three complete sentences each. Name the discussion posting after yourself + the name of your project. This discussion posting will need to include a brief discussion of what the project is supposed to do, and what it currently is able to do. Also, if you have run across any difficulties, please include that as part of your post
B) Each of you is required to comment on at least two of the other discussion postings. Extra credit will be awarded for making truly helpful suggestions to your classmates as part of your comments. By helpful, I do not mean posting the equivalent of "man, you should really try not to have your project suck". Try to offer specific guidance, if you can.
btw, there is no real limit to the amount of extra credit you can get for offering assistance to your fellow coders
C) Work on your projects, and upload them before the end of the class
Cheers,
Mr. L
Thursday, October 23, 2008
Fri Oct 24: yet more fun with menus
More code to add to your menu:
First, add this code to THE VERY TOP of your code sheet, above where it says “Public Form1”
Imports System.IO.File
If you recall from our “Crypto” program, this allows you to create and save files in VB
Next, just beneath “Public Form1’ create the following variable:
Dim saveFolder As String
Next, give this variable a value in “Form Load”, something like this:
"C:\Documents and Settings\Paul\My Documents\Visual Studio 2005\Projects\PaulLaRueMenus\"
It’s the pathname for a folder; your pathname will be different, since you are not me
Finally, doubleclick on the SAVE command, and then add this code to it:
Dim myFile As System.IO.File
'create a file writer
Dim myWrite As System.IO.StreamWriter
'set the folder and name of file where contents of textbox will be written
myWrite = IO.File.CreateText(saveFolder & "My Words.doc")
'write the contents of your textbox to a file
myWrite.WriteLine(MyWords.Text)
'closes the file no more writing to it
myWrite.Close()
Now, SAVE your work, then run the program and see if you can save a text file from the text you type in your textbox
Cheers,
Mr. L
Friday October 24: fun with menus
A) using menus in your VB applications
B) working on your projects
and btw, you need to pass in both these items today before the class is done!
Anyway, lets get going with menus. The first step is to start a new VB project, and name it after yourself plus the word "menus".
Next, scroll down in the list of controls at the left and drag a "MenuStrip" onto your form. It doesn't matter where, since its just a container, and the real guts of it will always go up at the top of the form
Next, go up top to where those "guts" are; it will say "TYPE HERE" click there, and type the word "FILE" then hit the Enter key
Repeat this process four more times, adding the following menu items:
NEW
OPEN
SAVE
EXIT
Save your work, then run the program to make sure your new menu looks OK. You should be able to click on all of the menu items, but they won't do anything....yet!
OK, now to make one of your menu items actually do something. Doubleclick on the "EXIT" menuitem to get into it's code, then type in this code:
Me.Close( )
Save, then run the program. See if the EXIT command now brings you out of the program.
Does it work? Cool! OK, let's do one last thing: Add a textbox to your form, re-size it so that it takes up most of the form. In the Properties sheet at the right, rename the textbox to "MyWords" and set its "Multi-line" value to TRUE. When you're ready, I have some very interesting code for you
Cheers,
Mr. L
Wednesday, October 22, 2008
Thurs, Oct 23: How to properly zip and upload
Today, before you get to work on your projects, I would like to take this opportunity to remind you of the importance of HANDING YOUR WORK IN ON TIME. Some of you have already lost points for not bothering to upload as I have demonstrated and as I have insisted that you do.
I believe this to be so important that I am including a series of instructions on how to upload your Projects:
A) After working on your project, notice that it is about 5 to 10 minutes before the end of the period
B) Save all your work, then close Visual Basic
C) Get into your "Projects" folder by going to "My Documents", then Visual Studio 2005, then into the Projects folder
D) Inside this main Projects folder, you should see many other folders, including the one which contains your current project
E) Create a new Winzip file next to this current project folder by right clicking in a blank space, then going to NEW then Winzip
F) Rename this Winzip file so that the filename includes your name, the name of your project and todays date as a number; for example "PaulLaRueMissionRisk1023"
G) Drag your current project folder onto this winzip file, then click the Add button
H) Get online and go to your shared "VBDepot" folder on Box.net. Upload the zip file you created
It's really that simple. From now on, do it before the end of EVERY CLASS.
Cheers,
Mr. L
Tuesday, October 21, 2008
Tuesday Oct 21: more project work, and commenting, and not dying of heat exhaustion
If you please, today I would like to do three things with you:
A) Make sure that you have commented the relevant parts of your program, including the comments at the very top if your program has been modified. (This way if you've slacked off on commenting, I will never know the difference!)
'Commenting is important, and will be important in your near future
B) Continue working on your projects, and make sure to hand them in before the end of class
C) Try not to wilt from the heat....apparently, they're trying to make sure we're snug and cozy up here. What I wish they would realize is that in cyberspace, the best warriors are COLD warriors.
Cheers,
Mr. L
Sunday, October 19, 2008
Mon Oct 20: help files and the web browser control
and welcome back from your weekend! Today, before you work on your projects, I want to demonstrate to you how to use a RIDICULOUSLY simple control that has many uses: the web browser control. Here's what you will do:
A) start a new project and name it after yourself plus the letters "WWW"
B) in the form that opens up, drag onto it a button, a textbox and a "webbrowser" control. This last is waaaaaaaayyy down towards the bottom of your list of controls
C) Doubleclick on the button to get into its code
D) Type in the name of your webbrowser control -- most likely it's called "Webbrowser1"
E) type in the period "." This will bring up a list of stuff you can do with this control, including -- oh please, just let it come -- "Navigate"
F) Next, type an opening parenthesis "(", then type in the name of the Textbox, which is probably going to be "TextBox1"
G) Type in the "." again, then choose "Text"
OK, that ought to do it. Run the program, and then type a website address in the textbox, then hit the button; the chosen website should appear in the webbrowser control
SO, what is this control good for? Well for one, it's cool all by itself. More specifically, you can set up some online help, or even offline help in the form of a webpage that goes with your program. It's a lot easier to pack useful information like that in this format, and be able to call it up from your program in this fashion.
OK, enough preaching: be sure to upload this very small and easy to make project to our "Depot" folder. Then, work on your own project some more, and upload that too before the end of the period.
Cheers,
Mr. L
Wednesday, October 15, 2008
Wed October 15: I need your projects NOW and at the END of the class too!
Today, before you do anything, you need to UPLOAD the project you are working on. You were supposed to do this yesterday; here are the names of the people who actually did that:
Erik Johnson
Callum Bushe & Jacob Mokler
Evan Kollmeyer
The rest of you need to upload your projects NOW
Once you are done with that, you have the entire class to work on this project -- again (Two whole days in a row -- whoo hoo!!)
Five minutes before the class ends, upload this file as well
Cheers,
Mr. L
Monday, October 13, 2008
Tues October 14 Comments: not just for breakfast anymore.
TELL ME WHAT YOUR PROGRAM IS ALL ABOUT
and here's the particulars:
A) I want you to do this telling as a block of comments at the very top of your program
B) The easiest way to make a comment is to put a ' at the beginning of each comment line. It's kind of liking putting // at the beginning of each line in a JAVA program or REM at the beginning of each line in Qbasic.
C) Your comments will have to include at least four different things this program will be able to do when you are done, and it should also list the components -- buttons, labels, textboxes etc-- you plan on using and how these components will interact with the code you are writing.
D) You will need to put a date at the very beginning of your comments, as well as the author name or names -- in other words, who is creating this thing?
When you are done with that, you have the rest of the class, except for the last five minutes, to work on your project.
When it is five minutes 'til the end of the class, you will need to make a zip file, name it after yourself plus the word "Project" plus today's date.
Upload that zip file to our account at BOX.net
Cheers,
Mr. L
Tuesday, October 7, 2008
Wed October 8: File creation and for loops
Today we will be accomplishing two distinct goals
A) You will continue to work on your ongoing projects....but FIRST
B) I will demonstrate to you how easy it is to create, save and write to files in Visual Basic. We will create our first "General Declaration", in which we import some code that's already pre-written in the VB language. This code will allow us to do the work with files
We will also use a "for loop" to take all the stuff in your array -- meaning all the letters-- and write it to your file, one line at a time. I'll explain a little more about exactly what a loop is and how it works at that time
btw, this time, I have handouts :-)
Cheers,
Mr. L
this is a private sub for the keydown event
If e.KeyCode = Keys.A Then
whichKey = 0
ElseIf e.KeyCode = Keys.B Then
whichKey = 1
ElseIf e.KeyCode = Keys.C Then
whichKey = 2
ElseIf e.KeyCode = Keys.D Then
whichKey = 3
ElseIf e.KeyCode = Keys.E Then
whichKey = 4
ElseIf e.KeyCode = Keys.F Then
whichKey = 5
ElseIf e.KeyCode = Keys.Space Then
whichKey = 26
ElseIf e.KeyCode = Keys.F11 Then
MsgBox("Do you want to save your label?")
allTheWords = secretCode.Text
wordsGoHere.Text = allTheWords
wordsGoHere.Visible = True
End If
secretCode.Text = secretCode.Text & CodeKeys(whichKey)
End Sub
put this stuff in the section where you first declared your variables
Dim whichKey As IntegerDim whichLetter As StringDim allTheWords As String
And add this array there:
Dim CodeKeys() As String = {"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M", " "}
Sunday, October 5, 2008
Tuesday October 7: I'm grateful to be here
O EQDT QEKGLL QF TDHZN LHQET
ZKTDWSTR QFR TBHSGRTR
STYZ Q WXL LZGH OF OZL HSQET
Ok, now that I have your attention, today we are going to be extending our understanding of arrays, variables and keyboard events by working on a separate assignment which allows you to create encrypted messages (secret codes, that is). Here is what you need to do before I hand you out the actual code sheets:
A) create a project and name it "Crypto" plus your first name and last Initial
B) add to your form a label and name the label "secretCode"
C) add a textbox, name it "wordsGoHere" and set its visibility to false
D) click on the "F7" key to get into your code, and outside of any control, type in the following code:
Dim whichKey As Integer
Dim whichLetter As String
Dim allTheWords As String
E) get into the "Form Load" part of your code, and add this code:
'set default as first element in the array
whichKey = 0
'set the letter that is going
'into the label as the first letter in the array
whichLetter = CodeKeys(whichKey)
F) Once you're done with that, I will hand out the rest of the code you will need to begin completing this assignment.
When you're done with this assignment, you will need to upload it so that I can see how well you've done. After that, feel free to work on your projects!
cheers,
Mr. L
Friday, October 3, 2008
Friday October 3: as you were gentlemen!
Today is Friday. And a "spirit" day. And people are spirited. So here is all you need to do:
A) work on your current projects
B) zip them up and email them to me
C) post a discussion on how you are doing thus far, including any discoverioes and any concerns
that'll do
Mr. L
Thursday, October 2, 2008
Thursday Oct 2: Before you work on your projects, or continue with amkeup work!
It has come to my attention that many of you are being prompted to "activate" your copy of Visual Basic. I was having the same problem, and I fixed it. Here is how you do it (and hopefully it will work for you too!):
A) Go to www.hotmail.com, and then click on the SIGNUP button in the middle of the screen
B)On the next page underneath the words "Windows Live Hotmail" click the GET IT button
C)On the next page fill in all the necessary information, and be sure to set the email type to HOTMAIL -- I cannot guarantee that a live.com account will work
D)Click the I ACCEPT button to bring you to your new account
E) LEAVE YOUR NEW HOTMAIL ACCOUNT OPEN
F) Turn on Visual Basic and when that thing near the system clock comes up to "activate" Visual Basic, click on it
G) This should bring you to a webpage where you have to fill out a form, complete with your new hotmail address, and then submit the form
H) You should receive an "activation code" and instructions on how to use it in your new hotmail inbox.
I) Follow the instructions, and let's see if we can solve this problem
Once we are done with this, I will be continuing to make last minute updates to your grades, and you will be working on your new projects BEFORE THE END OF THE CLASS, you will need to ake a new discussion posting talking about the progress you have made on this new project. When you make the discussion posting, please put todays date in the subject line, along with "Project Progress" plus your name.
Cheers,
Mr. L
