首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

C#的代码转换为VB.net,不能用作表达式错误!

2014-01-28 
原始帖子在: http://www.cnblogs.com/fox23/archive/2008/12/24/windows-mobile-ril-in-compact-framework.

原始帖子在:
http://www.cnblogs.com/fox23/archive/2008/12/24/windows-mobile-ril-in-compact-framework.html

原始的C#代码:
http://files.cnblogs.com/fox23/CellIDSample.rar


----------------------------------------------------------------------------------------------------------


我把其中的一个RILHelper.cs 转为 RILHelper.vb,转换之后有3处错误见红色和黑体部分,代码如下,这个是在compact framework下的,不过应该和.net是一样的,可能是哪里定义错误了,请大家帮忙debug一下.


Imports System.Runtime.InteropServices
Imports System.Threading


Namespace RILDriver


Friend Class RILHelper


  <DllImport("ril.dll")> _
  Private Shared Function RIL_Deinitialize(ByVal hRil As IntPtr) As IntPtr
  End Function

  <DllImport("ril.dll")> _
  Private Shared Function RIL_GetCellTowerInfo(ByVal hRil As IntPtr) As IntPtr
  End Function

  <DllImport("ril.dll")> _
  Private Shared Function RIL_Initialize(ByVal dwIndex As UInt32, ByVal pfnResult As RILRESULTCALLBACK, ByVal pfnNotify As RILNOTIFYCALLBACK, ByVal dwNotificationClasses As UInt32, ByVal dwParam As UInt32, <Out()> ByRef lphRil As IntPtr) As IntPtr
  End Function


  Public Delegate Sub RILNOTIFYCALLBACK(ByVal dwCode As UInt32, ByVal lpData As IntPtr, ByVal cbData As UInt32, ByVal dwParam As UInt32)
  Public Delegate Sub RILRESULTCALLBACK(ByVal dwCode As UInt32, ByVal hrCmdID As IntPtr, ByVal lpData As IntPtr, ByVal cbData As UInt32, ByVal dwParam As UInt32)


  ' Methods
  Public Shared Function GetCellTowerInfo() As String
  Dim hRil As IntPtr = IntPtr.Zero
  Dim hRes As IntPtr = IntPtr.Zero
  RILHelper.celltowerinfo = ""


  '错误:“rilResultCallback”是一个类型,不能用作表达式
  If (RIL_Initialize(1, New RILRESULTCALLBACK(AddressOf rilResultCallback), Nothing, 0, 0, hRil) <> IntPtr.Zero) Then
  Return "Failed to initialize RIL"
  End If

  hRes = RIL_GetCellTowerInfo(hRil)
  waithandle.WaitOne()         

热点排行