Lost Password?

  #1 (permalink)  
Old 09-08-2007, 07:07 AM
travy92's Avatar   
travy92 travy92 is offline
Learning Programmer
 
Join Date: Sep 2007
Location: Australia
Age: 15
Posts: 71
Rep Power: 4
travy92 is on a distinguished road
Send a message via MSN to travy92
Post Tutorial - Smarterchild copy

Well basically i've been learning VB 6.0 (Visual Basic 6.0) for about 2 weeks now and i've come quiet far.

So i've decided to make a tutorial on a simple program that responds to your words(made completely by ME, but i was helped by a few tutorials). It will use a different color the express what it's saying when you say specific words/anything. You can check the code for the words lol.

Well here it goes:

First open up VB 6.0.

Then make a few command buttons depending on how many responses you want to have.

Put their names as cmd"Blah" ("Blah" means put it as whatever you want it to be eg. "cmdName" would be the button to click to enter your name.

Captions can be whatever you want.
----------------------------------------------------------------
Now, for the coding:

Quote:
Private Sub cmdName_Click()
Dim strName As String



strName = InputBox("Enter your name:", "Name")

Select Case strName
Case "Trevor"
frmTest.ForeColor = vbGreen
Print "Hello there, "; strName; "."
Print "How old are you?"
Case Else
frmTest.ForeColor = vbPink
Print "Hello there, "; strName; "."
Print "How old are you?"


End Select
End Sub
----------------------------------------------------------------
Code Explanation:

Quote:
strName = InputBox("Enter your name:", "Name")
Makes the InputBox (Box that requires you to type a response in)
with the title "Name" and the message "Enter your name:"

----------------------------------------------------------------
Quote:
Case "Trevor"
frmTest.ForeColor = vbGreen
Print "Hello there, "; strName; "."
Print "How old are you?"
Also the above code would cause the form to be printed with:

Quote:
"Hello there, ";strName; "."
"How old are you?"
The ;strName; is the "String" or response of the person In this case it's:

Case "Trevor" (meaning if the person answered "Trevor" as their name, it would print "Hello there, Trevor" and "How old are you?" in green.)
----------------------------------------------------------------

Quote:
Case Else
frmTest.ForeColor = vbRed
Print "Hello there, "; strName; "."
Print "How old are you?"
This code would print the text:
"Hello there,"; strName; "."
"How old are you?"

ONLY if the response of the person was something other then "Trevor".

P.S - You may have noticed that i put:
Quote:
"Hello there,"; strName; "."
"How old are you?"
Twice in both of the "Case" codes, this is kind of like insurance so that it will actually print something rather then nothing. (I found that if i didn't add it twice, it would only print those lines if i answered "Trevor" as the response.

And as always before the "End Sub" function in the code, put a
"End Case" to end the "Case"

Please note that there will be an error if you don't add the
"End Case" function to the coding.
----------------------------------------------------------------

Ok now we're done with the code for your name.

You can use the same structure for every button.
eg. cmdAge (cmdAge is the name for the button and Age would be the caption) would be:

Quote:
Private Sub cmdAge_Click()
Dim strAge As String



strAge = InputBox("Enter your Age:", "Age")

Select Case strName
Case "14"
frmTest.ForeColor = vbWhite
Print "WoW! "; strAge; " Years young!"
Print "What country do you live in"; strName; "?"
Case Else
frmTest.ForeColor = vbBlack

Print "WoW! "; strAge; " Years young!"
Print "What country do you live in"; strName; "?"



End Select
End Sub
And so on....
----------------------------------------------------------------
Code Explanation:

Quote:
strAge = InputBox("Enter your Age:", "Age")
Makes the InputBox (Box that requires you to type a response in)
with the title "Age" and the message "Enter your Age:"
----------------------------------------------------------------
Quote:
Case "14"
frmTest.ForeColor = vbWhite
Print "WoW! "; strAge; " Years young!"
Print "What country do you live in"; strName; "?"
The above code would cause the form to be printed with:

[QUOTE"]"WoW! "; strAge; " Years young!"
"What country do you live in"; strName; "?"[/quote]

The ;strAge; is the "String" or response of the person In this case it's:

Case "14" (meaning if the person answered "14" as their age, it would print ""WoW! "; strAge; " Years young!" and "What country do you live in"; strName; "?" in White)


----------------------------------------------------------------

Quote:
Case Else
frmTest.ForeColor = vbBlack
Print "WoW! "; strAge; " Years young!"
Print "What country do you live in"; strName; "?"
This code would print the text (In black as specified):
"WoW! "; strAge; " Years young!"
"What country do you live in"; strName; "?"

ONLY if the response of the person was something other then "14".

P.S - You may have noticed that i put:
Quote:
"WoW! "; strAge; " Years young!"
"What country do you live in"; strName; "?"
Twice in both of the "Case" codes, this is kind of like insurance so that it will actually print something rather then nothing. (I found that if i didn't add it twice, it would only print those lines if i answered "14" as the response.

And as always before the "End Sub" function in the code, put a
"End Case" to end the "Case"

Please note that there will be an error if you don't add the
"End Case" function to the coding.
----------------------------------------------------------------

So basically just change the str"blah" ("blah" being what you're asking eg. Age, Name, location.) according to what you're asking for each of the command buttons.
eg. strName
strAge
strCountry

And so on..

Also if you wanted to clear the text from the form.... Make a new button with the name "cmdClear" and Caption "Clear text"
Then open up the code for it and use this code:

Quote:
Private Sub cmdClear_Click()
Cls
End Sub
If you need any further assistance please pm me or feel free to ask on this thread.

I've enclosed a sample.

EDIT - I've also added my GUI (My layout of the SmarterChild copy)



EDIT - I've re-attached the samples.

Thanks for the feedback!

Once again this tutorial was made completely by me, Travy92 but i had some help from oOTheNerdOo (The "Select Case" part) and thanks to tcm9669 for the screenshot program!.
Attached Files To view attachments your post count must be 1 or greater. Your post count is 0 momentarily.

Last edited by Jordan; 09-10-2007 at 08:15 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-08-2007, 07:17 AM
travy92's Avatar   
travy92 travy92 is offline
Learning Programmer
 
Join Date: Sep 2007
Location: Australia
Age: 15
Posts: 71
Rep Power: 4
travy92 is on a distinguished road
Send a message via MSN to travy92
Post

OH! OMG. Admins could you please move this to Visual Basic tutorials section? I accidently posted it in VB prgramming sections.. Sorry!

And could ya please change the title of the thread to "Tutorial - Smarterchild copy" ?

Thanks.

EDIT - Thanks Jordan for moving it and renaming it.

Last edited by travy92; 09-08-2007 at 08:50 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-08-2007, 09:24 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 25
Posts: 4,565
Last Blog:
PHP: list()
Rep Power: 50
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

Hey Travy92, nice tutorial! I'll move this to the tutorial section and change the title.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Don't hesitate to ask any questions that you have! Check out our ASCII Calculator!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-08-2007, 11:02 AM
TcM's Avatar   
TcM TcM is offline
Terminator - I'll be back
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 5,748
Rep Power: 47
TcM is a jewel in the roughTcM is a jewel in the roughTcM is a jewel in the rough
Default

Yes - I must admit it's a nice tutorial I'm going to download and test it.

EDIT:- The Zip/Rar Files are empty!

And Just a Tip, when you are talking about copies of scripts/programs etc.. you say Clone, not copy. So it should be 'Smarterchild Clone' just to let you know.. but it's up to you.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall


Business Directory | Technology Blog | Windows Help

Last edited by TcM; 09-08-2007 at 11:05 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-14-2007, 08:56 AM
compil003 compil003 is offline
Newbie
 
Join Date: Sep 2007
Posts: 1
Rep Power: 0
compil003 is on a distinguished road
Default

It`dose look sound i will have to take a look at the source to see what it really looks like.

Edit:
you may want to check your code for people entering incorrect data
example how old are you I entered "HG" which are not numbers, if you were to make a textbox you could place this code in the program.
Code:
Select Case KeyAscii
Case 8
Case 13
Case 48
Case 49
Case 50
Case 51
Case 52
Case 53
Case 54
Case 55
Case 56
Case 57
Case 127

Case Else
MsgBox "Alpha Charecters are not permited", vbInformation, "error"
KeyAscii = 0
end select
this code would have to be in this sub

Private Sub Txtinput_KeyPress(KeyAscii As Integer)

presuming you box would be Txtinput

Before someone thinks that I'm stupid i have no education background in programing and i'm sure that there are better ways of doing this out there. but this is the one i found that worked for me.

you could i guess do it using and if statement, like
Code:
If keyascii <> 8 or keyascii <> 13 or keyascii <> 48 or keyascii <> 49 or keyascii <> 50 or_
keyascii <> 51 or keyascii <> 52 or keyascii <> 53 or keyascii <> 54 or keyascii <> 55_
or keyascii <> 56or keyascii <> 57 or keyascii <> 127 then
keyascii=0
end if
*this one has not been tested but i think it should work. I hope
they would both go in the same sub the 2 method should work at any time but will only let you do 1234567890 enter del and backspace wihich should be ok...

Last edited by compil003; 09-14-2007 at 09:18 AM. Reason: add comments for the author
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 09-14-2007, 07:57 PM
travy92's Avatar   
travy92 travy92 is offline
Learning Programmer
 
Join Date: Sep 2007
Location: Australia
Age: 15
Posts: 71
Rep Power: 4
travy92 is on a distinguished road
Send a message via MSN to travy92
Default

Oh, yeah ! Thanks for the tip. I'll use it in my next tutorials if i'm making a tut on a similar program!
__________________
Quote:
The pacifist's task today is to find a method of helping and healing which provides a revolutionary constructive substitute for war.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 10-14-2007, 11:35 PM
coco123 coco123 is offline
Newbie
 
Join Date: Oct 2007
Posts: 2
Rep Power: 0
coco123 is on a distinguished road
Default

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-06-2007, 02:23 PM
Amoon Amoon is offline
Newbie
 
Join Date: Nov 2007
Posts: 1
Rep Power: 0
Amoon is on a distinguished road
Default

Thx for the tutorial ! =)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-22-2007, 04:43 PM
josh_the_insane_prince josh_the_insane_prince is offline
Newbie
 
Join Date: Nov 2007
Posts: 1
Rep Power: 0
josh_the_insane_prince is on a distinguished road
Talking hlped

this helped a whot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 12-08-2007, 07:20 PM
Goatz Goatz is offline
Newbie
 
Join Date: Dec 2007
Posts: 1
Rep Power: 0
Goatz is on a distinguished road
Default

This is pretty useful but im having trouble understanding how can i make it so it automaticly talks to my messenger list?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: C# Hello World Jordan CSharp Tutorials 13 06-26-2008 08:57 AM
John's Java Tutorial Index John Java Tutorials 0 01-11-2007 03:05 PM
A time showing tutorial ahsan16 VB Tutorials 1 01-10-2007 04:50 AM
JSP Tutorial encoder JavaScript and CSS 0 05-26-2006 05:31 AM


All times are GMT -5. The time now is 01:51 AM.

Contest Stats

dargueta ........ 93.00000
John ........ 87.50000
Xav ........ 70.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads