+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Tutorial - Smarterchild copy

  1. #1
    travy92's Avatar
    travy92 is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    76
    Rep Power
    17

    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:

    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:

    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:"

    ----------------------------------------------------------------
    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:

    "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.)
    ----------------------------------------------------------------

    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:
    "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:

    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:

    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:"
    ----------------------------------------------------------------
    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)


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

    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:
    "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:

    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 Attached Files
    Last edited by Jordan; 09-10-2007 at 06:15 AM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    travy92's Avatar
    travy92 is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    76
    Rep Power
    17

    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 06:50 PM.

  4. #3
    Jordan Guest
    Hey Travy92, nice tutorial! I'll move this to the tutorial section and change the title.

  5. #4
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101
    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.
    Last edited by TcM; 09-08-2007 at 09:05 AM.

  6. #5
    compil003 is offline Newbie
    Join Date
    Sep 2007
    Posts
    1
    Rep Power
    0
    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 07:18 AM. Reason: add comments for the author

  7. #6
    travy92's Avatar
    travy92 is offline Learning Programmer
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    76
    Rep Power
    17
    Oh, yeah ! Thanks for the tip. I'll use it in my next tutorials if i'm making a tut on a similar program!
    C:\Users\Travis\Desktop\Image Converter\Knight1.bmp

  8. #7
    coco123 is offline Newbie
    Join Date
    Oct 2007
    Posts
    2
    Rep Power
    0
    thanks

  9. #8
    Amoon is offline Newbie
    Join Date
    Nov 2007
    Posts
    1
    Rep Power
    0
    Thx for the tutorial ! =)

  10. #9
    Join Date
    Nov 2007
    Posts
    1
    Rep Power
    0

    Talking hlped

    this helped a whot

  11. #10
    Goatz is offline Newbie
    Join Date
    Dec 2007
    Posts
    1
    Rep Power
    0
    This is pretty useful but im having trouble understanding how can i make it so it automaticly talks to my messenger list?

+ Reply to Thread
Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Clever copy
    By Esgrimidor in forum General Programming
    Replies: 1
    Last Post: 02-20-2011, 01:56 PM
  2. Copy mails to pc
    By xle_camry in forum PHP Development
    Replies: 1
    Last Post: 12-18-2010, 07:45 AM
  3. string copy
    By yangss in forum C and C++
    Replies: 3
    Last Post: 09-03-2010, 06:08 AM
  4. help copy file?
    By softvnn in forum C and C++
    Replies: 1
    Last Post: 09-02-2008, 08:18 AM
  5. Copy RAM to HDD: Beginner
    By ChappyChaps11 in forum C and C++
    Replies: 2
    Last Post: 03-28-2008, 07:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts