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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

785 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