将下例c语言转换成vb语言

来源:百度知道 编辑:UC知道 时间:2024/09/28 01:27:08
将下例c语言转换成vb语言
#include "math.h"
#include "graphics.h"
int Base=0x220;

DA(int port, double da_out)
{
short high,low;
int data;
data=da_out*4095.0/10.0;
low=data&0xff;
high=(data>>8)&0x0f;
outportb(Base+4+port*2,low);
outportb(Base+5+port*2,high);
}

int AD (int port)
{
short high,low,temp;
int outdata;
outportb(Base+10,port);
outportb(Base+9,0);
outportb(Base+11,1);
outportb(Base+12,0xff);
temp=inportb(Base+5);
temp=temp&0x10;
while(temp==0x10)
{
temp=inportb(Base+5);
temp=temp&0x10;
}
high= inportb(Base+5);
low = inportb(Base+4);
outdata=high&0x0f;
outdata=outdata<<8;
outdata=outdata+low;
return(outdata);
}

自己去下载 DecLib.dll 文件 (还有要给我追加分数哈!!!)

============================================
Option Explicit

Private Declare Function OpenDecPort Lib "DecLib.dll" Alias _
"[email=_OpenDecPort@0]_OpenDecPort@0[/email]" () As Boolean
Private Declare Sub ClosePort Lib "DecLib.dll" Alias _
"[email=_CloseDecPort@0]_CloseDecPort@0[/email]" ()
Private Declare Function outportb Lib "DecLib.dll" Alias _
"[email=_outportb@8]_outportb@8[/email]" (ByVal PortAddress As Long, _
ByVal state As Byte) As Boolean
Private Declare Function outport Lib "DecLib.dll" Alias _
"[email=_outport@8]_outport@8[/email]" (ByVal PortAddress As Long, _
ByVal state As Long) As Boolean

Private Declare Function inportb Lib "DecLib.dll" Alias _
"[email=_inportb@4]_inportb@4[/email]" (ByVal PortAddress As Long) As Byte
Private D