Results 1 to 7 of 7

Thread: why isnt it working ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    116

    Question

    what's wrong with this code?

    private sub test(ctl as textbox)
    ctl.text="blah blah"
    end sub

    private sub txttest_gotfocus()
    test(txttest)
    end sub

    in this code i want to write blah blah when the textbox
    get focus, but when the control does get focus in run
    time, an error message pops up saying "type mismatch"

    (i tried to write "ctl as control", but it didnt work as well)
    10x,
    Amos

  2. #2
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Worldwide in the Sun
    Posts
    566
    Why not putting your text immediately in the gotfocus.


    private sub text1_GotFocus()

    text1.text = "blablabla"

    end sub


    greetz
    Ray
    Ray

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Originally posted by murphy
    what's wrong with this code?

    private sub test(ctl as textbox)
    ctl.text="blah blah"
    end sub

    private sub txttest_gotfocus()
    test(txttest)
    end sub

    in this code i want to write blah blah when the textbox
    get focus, but when the control does get focus in run
    time, an error message pops up saying "type mismatch"

    (i tried to write "ctl as control", but it didnt work as well)
    As for the task of displaying a fixed caption when your textbox receives focus, marex has answered it. And as for why your code is not working, remove the parenthesis around txttest and re-write the code as:

    Code:
    private sub txttest_gotfocus()
       test txttest
    end sub
    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    116

    Thumbs up gr8, it worked...but

    what is the diferrence between putting the params
    inside a parenthesis or without ?
    10x,
    Amos

  5. #5
    Hyperactive Member kourosh's Avatar
    Join Date
    Aug 1999
    Location
    Vancouver, British Columbia, Canada
    Posts
    256

    Just a guess

    My guess is you need the paranthesis only when you are assigning it to a variable.
    ===========================
    Kourosh Gonabadi
    VB Programmer
    C++ Newbie
    Graphic Designer
    ===========================

  6. #6
    Fanatic Member ExtremePimpness's Avatar
    Join Date
    Jan 2001
    Location
    Indianapolis, Indana - USA
    Posts
    550
    or if you are passing a variable and not an object.?!?.!

  7. #7
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Parentheses are required only for a function which returns a value. Since procedures don't return a value you need not put the parameters in parentheses.

    Just for fun's sake, try the following code. I have not tested it myself, but I guess it will work:

    Code:
    Private Sub txttest_GotFocus()
       Call Test(txttest)
    End Sub
    I guess if you omit the parentheses now, you will get an error. Because this time you are using the Call method to execute the procedure.

    As I said, it may not be the case, since I have never tried it myself.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

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



Click Here to Expand Forum to Full Width