ParamArray Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mafaisal
    New Member
    • Sep 2007
    • 142

    ParamArray Problem

    Hello Experts

    See My Code

    [CODE=vb]Private sub F_Clear(Paramar ray Cntr())
    dim i%
    For i=0 to ubound(cntr)
    cntr(i).text = ""
    next
    End sub[/CODE]

    In this procedure when I call this error is coming
    Any Bugs in the code
    Error is

    F_Clear (TxtBox(0),TxtB ox(2))
    Compile Error
    Expected: =
    Last edited by Killer42; Feb 12 '08, 09:02 PM. Reason: Added CODE=vb tag
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by mafaisal
    Hello Experts

    See My Code

    Private sub F_Clear(Paramar ray Cntr())
    dim i%
    For i=0 to ubound(cntr)
    cntr(i).text = ""
    next
    End sub


    F_Clear (TxtBox(0),TxtB ox(2))
    Compile Error
    Expected: =
    I dont know what the problem might be. I tried it using two textboxes, and it cleared them without any problem. May be your textboxes have some issues.

    btw, i liked your avatar.

    HTH

    Comment

    • mafaisal
      New Member
      • Sep 2007
      • 142

      #3
      Hello Kadghar
      Thanx For Reply
      Hw u try
      Plz Give me
      textboxe have wat pblm occure, if it is one then no prob

      also Give u r trying code

      I will

      Faisal

      Originally posted by kadghar
      I dont know what the problem might be. I tried it using two textboxes, and it cleared them without any problem. May be your textboxes have some issues.

      btw, i liked your avatar.

      HTH

      Comment

      • kadghar
        Recognized Expert Top Contributor
        • Apr 2007
        • 1302

        #4
        Originally posted by mafaisal
        Hello Kadghar
        Thanx For Reply
        Hw u try
        Plz Give me
        textboxe have wat pblm occure, if it is one then no prob

        also Give u r trying code

        I will

        Faisal
        i created a new form with two textboxes : textbox1 and textbox2, then i copy pasted your sub, and in the click event of the form i called it:

        [CODE=vb]Private Sub F_Clear(ParamAr ray Cntr())
        Dim i%
        For i = 0 To UBound(Cntr)
        Cntr(i).Text = ""
        Next
        End Sub

        Private Sub UserForm_Click( )
        Call F_Clear(TextBox 1, TextBox2)
        End Sub[/CODE]

        then i run it, write something in each textbox and when i click on the form it clears both textboxes.

        HTH

        Comment

        • mafaisal
          New Member
          • Sep 2007
          • 142

          #5
          Hello Kadghar

          Thanx For

          It is wat is Usage of Using call Before Procedure

          I mean
          Call F_Clear(textbox 1)

          i just Call as
          F_Clear(textbox 1)

          When use call Bfore that it working

          Reply if u can

          Faisal

          Originally posted by kadghar
          i created a new form with two textboxes : textbox1 and textbox2, then i copy pasted your sub, and in the click event of the form i called it:

          [CODE=vb]Private Sub F_Clear(ParamAr ray Cntr())
          Dim i%
          For i = 0 To UBound(Cntr)
          Cntr(i).Text = ""
          Next
          End Sub

          Private Sub UserForm_Click( )
          Call F_Clear(TextBox 1, TextBox2)
          End Sub[/CODE]

          then i run it, write something in each textbox and when i click on the form it clears both textboxes.

          HTH

          Comment

          • werks
            New Member
            • Dec 2007
            • 218

            #6
            Hi guy'z the only thing differ between kadghar codes and mafaisal codes is that

            kadghar
            Code:
            Call F_Clear(TextBox1, TextBox2)
            mfaisal
            Code:
            F_Clear (TxtBox(0),TxtBox(2))

            --
            Kenneth
            "Better Than Yesterday"

            Comment

            • mafaisal
              New Member
              • Sep 2007
              • 142

              #7
              Hello

              Yes I Know, When Use Call that work
              My Question is Wat is the importants of Using Call...?

              Faisal

              Originally posted by werks
              Hi guy'z the only thing differ between kadghar codes and mafaisal codes is that

              kadghar
              Code:
              Call F_Clear(TextBox1, TextBox2)
              mfaisal
              Code:
              F_Clear (TxtBox(0),TxtBox(2))

              --
              Kenneth
              "Better Than Yesterday"

              Comment

              • kadghar
                Recognized Expert Top Contributor
                • Apr 2007
                • 1302

                #8
                Originally posted by mafaisal
                Hello

                Yes I Know, When Use Call that work
                My Question is Wat is the importants of Using Call...?

                Faisal
                I dont know. I thought it was the same using it or not.
                I have that "bad habit" of using it, but... seems that it solved the problem this time.

                There was a short discussion in this forum about using Call a few weeks ago, i'll see if i find it to ask why this is happening to some Expert...

                Ô_o (wait... )

                Comment

                • werks
                  New Member
                  • Dec 2007
                  • 218

                  #9
                  This might help you

                  Importance of Call


                  --
                  Kenneth
                  "Better Than Yesterday"

                  Comment

                  • kadghar
                    Recognized Expert Top Contributor
                    • Apr 2007
                    • 1302

                    #10
                    Originally posted by werks
                    This might help you

                    Importance of Call


                    --
                    Kenneth
                    "Better Than Yesterday"
                    I see... but they say you can use it for calling functions if you dont care about the return value. but... this is not a function!!!!

                    =( this time i have no idea why this is happening, i'll google some similar situations.

                    Comment

                    • mafaisal
                      New Member
                      • Sep 2007
                      • 142

                      #11
                      K, Thanx
                      So It Concluded That
                      Using of Call is Good Practice
                      Usually i did not use Call
                      K

                      Faisal

                      Originally posted by werks
                      This might help you

                      Importance of Call


                      --
                      Kenneth
                      "Better Than Yesterday"

                      Comment

                      • werks
                        New Member
                        • Dec 2007
                        • 218

                        #12
                        Originally posted by mafaisal
                        K, Thanx
                        So It Concluded That
                        Using of Call is Good Practice
                        Usually i did not use Call
                        K

                        Faisal
                        Yes! it is easier to identify codes.. you should start practicing it

                        Comment

                        • Killer42
                          Recognized Expert Expert
                          • Oct 2006
                          • 8429

                          #13
                          I've never used a ParamArray, so this might be incorrect. But my immediate response is that instead of
                          F_Clear (TxtBox(0),TxtB ox(2))
                          you should try
                          F_Clear TxtBox(0), TxtBox(2)

                          Comment

                          • Killer42
                            Recognized Expert Expert
                            • Oct 2006
                            • 8429

                            #14
                            Originally posted by werks
                            Yes! it is easier to identify codes.. you should start practicing it
                            Absolute rubbish! With the possible exception of a ParamArray (don't know yet) there's no reason to use Call.

                            EDIT: No, I've tried it, and the ParamArray has no effect. You don't need the Call either way. Just leave off the extra parentheses.
                            Last edited by Killer42; Feb 12 '08, 09:11 PM.

                            Comment

                            • kadghar
                              Recognized Expert Top Contributor
                              • Apr 2007
                              • 1302

                              #15
                              Originally posted by Killer42
                              I've never used a ParamArray, so this might be incorrect. But my immediate response is that instead of
                              F_Clear (TxtBox(0),TxtB ox(2))
                              you should try
                              F_Clear TxtBox(0), TxtBox(2)

                              Not incorrect at all, it worked great.

                              Comment

                              Working...