Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-08-18
3
Medium Priority
?
530 Views
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
    Loop
    
End Function

Open in new window

0
Comment
Question by:teeling
  • 2
3 Comments
 
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:
http://www.vbforums.com/showthread.php?t=451560#notoptional
0
 

Author Comment

by:teeling
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?

0
 

Accepted Solution

by:
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
    Loop
    
End Function

Open in new window

0

Featured Post

Independent Software Vendors: 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 (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 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…

773 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