Solved

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

Posted on 2010-08-18
3
396 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now