How to make a function in a method

Hi, I need to do a function in a method but I have a “syntax error”, I’m using the “cbw32.dll” library. I’m trying make a function that write a Byte with the next code:

[code] Function write_adc_byte (CFG As Integer) As Integer

Dim Var, Data,CS, CLK,ULStat, i As Integer
CS = 1 // Bit 0 of port A
CLK = 2 //Bit 1 of port A
Data = 4 //Bit 2 of port A

DataByte = DataByte And (Not CS)
ULStat = cbDConfigPort(BoardNum, PortNum, Direction)
ULStat = cbDOut(BoardNum, PortNum, DataByte)

For i = 0 To 7
  Var = CFG And Bitwise.Shiftleft(1, i)
  DataByte = DataByte Or CLK
  ULStat = cbDOut(BoardNum, PortNum, DataByte)
  If Var <> 0 Then
    DataByte = (DataByte And (Not CLK)) Or Data
    DataByte = (DataByte And (Not CLK))  And (Not Data)
  End If
  ULStat = cbDOut(BoardNum, PortNum, DataByte)
DataByte = DataByte Or CS
ULStat = cbDOut(BoardNum, PortNum, DataByte)

End Function[/code]

Where does the syntax error occur? Where is DataByte defined?

In the End function, I don’t Know for what say that. :confused:

You dont put the “function” and “end function” lines in

When you add a method the inspector (to the right hand side) is where you name the function ( in your case write_adc_byte ) and also where you put whatever parameters (CFG As Integer) and whatever return type (integer)

You dont define a function IN a method - you add a method that IS a function because it returns a value

Might it be that he has troubles with declares into the cbw32.dll?

Thanks, My question is resolved. :smiley: