台灣最大程式設計社群網站
線上人數
1890
 
會員總數:246038
討論主題:189625
歡迎您免費加入會員
討論區列表 >> VB6 >> [求救]將powerbasic程式轉換成VB程式
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
[求救]將powerbasic程式轉換成VB程式
價值 : 10 QP  點閱數:1535 回應數:0
樓主


門外漢
0 1
26 0
發送站內信

請教一下懂得PowerBasic語法的前輩:
小弟有一段程式碼是用PowerBasic語法寫的,主要的功能是透過網路模式連接主機,並讀取主機的資料,但是要和另一個VB程式結合時,因為不懂PowerBasic語法,所以請各位先進不吝指導。

該程式主要透過一個dLL檔處理通訊及資料處理的工作。
程式碼如下:

GLOBAL hDlg AS DWORD
GLOBAL DataIn() AS BYTE
GLOBAL DataDisp() AS BYTE
GLOBAL DataX() AS BYTE
GLOBAL Order AS BYTE

'External
DECLARE FUNCTION Open_UDP LIB "Irradiator_DLL.DLL" () AS LONG
DECLARE FUNCTION Close_UDP LIB "Irradiator_DLL.DLL" (UDP_Handle AS LONG) AS LONG
DECLARE SUB Broadcast LIB "Irradiator_DLL.DLL" (my_ipAddr AS LONG, ipAddr AS LONG, ipPort AS LONG, hUdp AS LONG)
DECLARE SUB DataXChange LIB "Irradiator_DLL.DLL" (ipAddr AS LONG, Buffer AS STRING, UDP_Modus AS LONG, hUdp AS LONG)

'Internal
==這邊開始要改成VB的語法========================
DECLARE FUNCTION DottedIP (BYVAL ip AS LONG) AS STRING
DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
#PBFORMS DECLARATIONS
遇到的問題:=======================================
1.DECLARE FUNCTION DottedIP 這個方式在VB中會產生錯誤,請問要怎麼修正?
2.DWORD是PowerBasic專屬的"雙位元組型"變數型態,在VB中可以用byte取代嗎?
================================================

FUNCTION DottedIP (BYVAL ip AS LONG) AS STRING
LOCAL x AS BYTE PTR
x = VARPTR(ip)
FUNCTION = USING$("#_.#_.#_.#", @x, @x[1], @x[2], @x[3])
END FUNCTION
遇到問題==============================================
1.ip 要用long的型態,但是一般ip的格式是192.168.x.xxx,要怎麼變成long的型態??
2.附上找到的USING$範例,但是要怎樣把上面的程式碼改成VB語法呢??

USING$ 函數
用途:返回格式化文本。
語法:sResult$ = USING$(fmtmask$遮罩, expr運算式 [, expr [, ...]])
備註:a$ = USING$ ("!", "abc") ' returns "a"
a$ = USING$ ("You owe $&#,.##", 12345.67@)' returns "You owe $12,345.67
DIM p AS BYTE PTR
HOST ADDR "localhost" TO ip&
p = VARPTR(ip&)
a$ = USING$ ("#_.#_.#_.#", @p, @p[1], @p[2], @p[3])' returns "127.0.0.1"
a$ = USING$ ("&=#.##############", "Pi", ATN(1)*4)' returns "Pi=3.14159265358979"
a$ = USING$ ("!", "AX", "BX", "CX")' returns "ABC"
a$ = USING$ ("&#.##_,", 1,20,300,4)' returns "$1.00,$20.00,$300.00,$4.00,"
a$ = USING$ ("$*=#####.##_,",1,20)' returns "$======1.00,$=====20.00,"
=============================================================

FUNCTION ShowData (DataX()AS BYTE, DataDisp()AS BYTE, DataIn() AS BYTE) AS LONG
LOCAL DlgNo AS DWORD
LOCAL I AS LONG
LOCAL Test AS STRING

FOR I = 0 TO 24
'All display data fields
IF ((I < 19) AND (I > 5)) OR (I = 22) THEN 'All input data fields
IF DataIn(I) < %Void THEN
IF DataIn(I) <> DataX(I) THEN
DataX(I) = DataIn(I)
DataIn(I) = %Void
END IF
END IF
END IF
IF (DataX(I) <> DataDisp(I)) THEN
DlgNo = I +1001
CONTROL SET TEXT hDlg, DlgNo, LTRIM$(STR$(DataX(I)))
DataDisp(I) = DataX(I)

END IF
NEXT I
END FUNCTION
遇到問題
1.CONTROL SET TEXT hDlg, DlgNo, LTRIM$(STR$(DataX(I))) 這一行看不懂 0.0"


另外連線時所使用的Function如下
'Getting the IP-Address(PS:這個功能寫在"Irradiator_DLL.DLL"檔內)
Broadcast(my_ipAddr as LONG,ipAddr as LONG,ipPort as LONG, UDP_Handle as LONG)
如果要呼叫這個功能副程式,請問要怎麼寫呢??

小弟有powerbasic的程式碼+dll檔的原始程式碼,若是能幫忙轉換成VB語法者,酬金相謝!!
轉換的程式碼只有一小段。
聯絡方式: holiday502@yahoo.com.tw 巫先生
msn: c2273@seed.net.tw


搜尋相關Tags的文章: [ powerbasic ] , [ 換 ] ,
本篇文章發表於2007-11-21 11:15
目前尚無任何回覆
   

回覆
如要回應,請先登入.