求用PB写的modbus与串口通讯源码解决方法

求用PB写的modbus与串口通讯源码
有举例源码也行
------解决方案--------------------
用mscomm控件

以下一个简单的例子,一个窗口源码:
forward
global type w_test from window
end type
type mle_1 from multilineedit within w_test
end type
type sle_1 from singlelineedit within w_test
end type
type st_1 from statictext within w_test
end type
type cb_2 from commandbutton within w_test
end type
type cb_1 from commandbutton within w_test
end type
type ole_1 from olecustomcontrol within w_test
end type
end forward

global type w_test from window
integer width = 2533
integer height = 1408
boolean titlebar = true
string title = "Untitled"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
mle_1 mle_1
sle_1 sle_1
st_1 st_1
cb_2 cb_2
cb_1 cb_1
ole_1 ole_1
end type
global w_test w_test

on w_test.create
this.mle_1=create mle_1
this.sle_1=create sle_1
this.st_1=create st_1
this.cb_2=create cb_2
this.cb_1=create cb_1
this.ole_1=create ole_1
this.Control[]={this.mle_1,&
this.sle_1,&
this.st_1,&
this.cb_2,&
this.cb_1,&
this.ole_1}
end on

on w_test.destroy
destroy(this.mle_1)
destroy(this.sle_1)
destroy(this.st_1)
destroy(this.cb_2)
destroy(this.cb_1)
destroy(this.ole_1)
end on

event resize;mle_1.x = 0
mle_1.width = this.width - 30
mle_1.height = this.height - mle_1.y
end event
type mle_1 from multilineedit within w_test
integer y = 164
integer width = 2469
integer height = 1124
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean vscrollbar = true
borderstyle borderstyle = stylelowered!
end type

type sle_1 from singlelineedit within w_test
integer x = 302
integer y = 24
integer width = 457
integer height = 108
integer taborder = 20
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type

type st_1 from statictext within w_test
integer y = 48
integer width = 297
integer height = 72
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
string text = "端口号:"
boolean focusrectangle = false
end type

type cb_2 from commandbutton within w_test
integer x = 1303
integer y = 8
integer width = 457
integer height = 128
integer taborder = 30
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "结束"
end type

event clicked;ole_1.object.portopen = false
end event

type cb_1 from commandbutton within w_test
integer x = 837
integer y = 12
integer width = 457
integer height = 128
integer taborder = 20
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "开始"
end type

event clicked;//li_com = profileint("baseparm.ini","com","com",3)
ole_1.object.commport = integer(sle_1.text)
ole_1.object.inputmode = 1
ole_1.object.portopen = true
end event

type ole_1 from olecustomcontrol within w_test