Why do I get Run-time error '449': Argument no optional?

Posted on 2010-08-18
Last Modified: 2012-05-10
When I run the program, I get the abovementioned error. Is it possible that it's caused by how I declare word1 and word2? Thanks.  Where command and argPassedIn are extracted
Function CommandCode(PC As Long)
    Dim command As String
    Dim argPassedIn As String
    command = Worksheets("GUI").Cells(PC + 1, 2).Value
    argPassedIn = Worksheets("GUI").Cells(PC + 1, 3).Value

    If InStr(argPassedIn, ",") = False Then CallByName Me, command, VbMethod, argPassedIn
    If InStr(argPassedIn, ",") Then CallByName Me, command, VbMethod, Split(argPassedIn, ",")
End Function

Function MySend(ByVal data As String)
    If LCase(data) = "chr(13)" Then data = Chr(13)
    If LCase(data) = "chr(27)" Then data = Chr(27)
    wsTCP.SendData data
End Function

Function CheckWarning(word1 As String, word2 As String)
'Detect whether there is a warning. If there is, keep sending word2.

    Do While (InStr(sBuffer, word1) > 0)   'Gets out of loop when word1 no longer exists
        sBuffer = ""
        MySend word2
        Call CheckBuffer
End Function

Open in new window

Question by:teeling
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 22

Expert Comment

by:Om Prakash
ID: 33472079
The error means that you are calling a Sub or Function but not specified enough parameters.
More info:

Author Comment

ID: 33472112
Split(argPassedIn, ",") actually splits the WARNING: Unable to issue or receive for item,Chr(32) into arrays where the first array contains  WARNING: Unable to issue or receive for item and the second array contains Chr(32).

Function CheckWarning(word1 As String, word2 As String) needs 2 arguments. I send the arrays into CheckWarning. Will this not work?


Accepted Solution

teeling earned 0 total points
ID: 33472318
I've got it working :)

Function CheckWarning(ByRef myarray As Variant)

    Do While (InStr(sBuffer, myarray(0)) > 0)   'Gets out of loop when word1 no longer exists
        sBuffer = ""
        MySend myarray(1)
        Call CheckBuffer
End Function

Open in new window


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question