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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 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