Results 1 to 4 of 4

Help with building a function to accept more that one parameter into a function.

  1. #1
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480

    Help with building a function to accept more that one parameter into a function.

    Hello, I have a little function that will clean up code moving forward.



    Code:
    Function SendEnterWait(Sendkey As String)
     
    With Session
    .TransmitANSI Sendkey
    .TransmitTerminalKey rcIBMEnterKey
    .WaitForEvent rcNewHostScreen, "10", "", 1, 1
    End With
    End Function
    Now this works just fine. Its firing keys into a reflections system, hitting enter. and then waiting up to 10 seconds to confirm the new screen is loaded.


    I'm wanting to expand on this, to make it look like.

    Code:
    Function SendEnterWait(Sendkey, SendKey2 As String)
    
    If IsMissing(SendKey2) = True Then
        Sendkey = SendKey2
    End If
    
    With Session
    .TransmitANSI Sendkey
    .TransmitANSI SendKey2
    .TransmitTerminalKey rcIBMEnterKey
    .WaitForEvent rcNewHostScreen, "10", "", 1, 1
    End With
    End Function
    But when I try to enter the function in a module I keep getting syntax errors.

    SendEnterWait("Hi","Hi2")


    I'm fresh out of the box with building functions, and there might be more than one issue with my formatting. Any tips would be amazing.

  2. #2
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Try:
    Function SendEnterWait(Sendkey As String, Optional SendKey2 As String)

  3. #3
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Quote Originally Posted by cyanidem View Post
    Try:
    Function SendEnterWait(Sendkey As String, Optional SendKey2 As String)
    The function seems to accept this. But when I try to type it in a sub it keeps giving me syntax errors. Arg
    Here is what I've tried.

    SendEnterWait("Hi","Hi2")
    SendEnterWait("Hi",)
    SendEnterWait("Hi",["Hi2"])

    Both are saying syntax error.

    but if I try

    SendEnterWait("Hi")

    It works great. Hmmm.

  4. #4
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    I'm an idiot. I'm not returning anything out of the function so ... it's a sub. Solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 03-09-2015, 05:36 PM
  2. Replies: 8
    Last Post: 11-04-2014, 10:44 PM
  3. Replies: 8
    Last Post: 01-31-2014, 01:45 PM
  4. Replies: 3
    Last Post: 12-28-2013, 09:13 AM
  5. Count + between + parameter function
    By teirrah1995 in forum Queries
    Replies: 3
    Last Post: 08-11-2011, 10:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums