Share via

Expression expected

kaveh rahimi 66 Reputation points
2021-06-06T19:42:38.753+00:00

I write these four lines in my code and receive 'BC30201' expression expected error.How can I resolve this error please help.
the lines are:
Private Declare Function ch341opendevice Lib "ch341dll.dll" (ByVal iindex As Integer) As Integer

Sub main()
    Console.WriteLine(ch341opendevice(Byval iindex as integer) As Integer)
End Sub
Developer technologies | VB

2 answers

Sort by: Most helpful
  1. Viorel 126.9K Reputation points
    2021-06-06T19:46:42.99+00:00

    Try something like this:

    Console.WriteLine( ch341opendevice(0) )
    

    Pass the correct parameter if 0 is not suitable.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Xingyu Zhao-MSFT 5,381 Reputation points
    2021-06-07T06:12:43.107+00:00

    Hi @kaveh rahimi ,
    A parameter of method should be a specific value or variable, not a declaration of another method.
    You need to pass the result of ‘ch341opendevice’ into ‘Console.WriteLine’ method.

        Sub Main()  
            Dim result As Integer = ch341opendevice(0)  
            Console.WriteLine(result)  
            Console.ReadLine()  
        End Sub  
    

    Best Regards,
    Xingyu Zhao
    *
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.