您的位置:程序门 -> 《程序员》杂志 -> 基本信息



以下程序可以在variant类型在各语言中的参数传递吗?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


以下程序可以在variant类型在各语言中的参数传递吗?
发表于:2008-01-26 18:11:55 楼主
private   sub   cmdreaddata_click()

        on   error   goto   toexit   '打开错误陷阱

        '------------------------------------------------

        dim   i   as   long

        dim   byttype   as   byte

        dim   lngret   as   long

        dim   lngdata()   as   long

        dim   fdata()   as   single

        dim   vdata   as   variant

 

        select   case   cmbtype.listindex

        case   0:   byttype   =   ppi_i

        case   1:   byttype   =   ppi_q

        case   2:   byttype   =   ppi_m

        case   3:   byttype   =   ppi_v

        case   4:   byttype   =   ppi_s

        case   5:   byttype   =   ppi_sm

        end   select

 

        s7_ppi1.fixaddr   =   cmbno.listindex   +   1

        lngret   =   s7_ppi1.readdata(val(txtaddr),   vdata,   val(cmbnum.text),   val(cmblen.listindex),   val(byttype))

       

        if   lngret   =   0   then

                txtdata   =   ""

                if   cmblen.listindex   =   3   then

                        fdata   =   vdata

                        for   i   =   1   to   val(cmbnum.text)

                                txtdata   =   txtdata   &   format(fdata(i   -   1),   "0.00")   &   "   "

                        next

                else

                        lngdata   =   vdata

                        for   i   =   1   to   val(cmbnum.text)

                                txtdata   =   txtdata   &   format(lngdata(i   -   1),   "0")   &   "   "

                        next

                end   if

        else

                txtdata   =   "error"

        end   if

 

        '------------------------------------------------

        exit   sub

        '----------------

toexit:

        msgbox   err.description

end   sub

private   sub   cmdwritedata_click()

        on   error   goto   toexit   '打开错误陷阱

        '------------------------------------------------

        dim   byttype   as   byte

        dim   strdata()   as   string

        dim   lngret   as   long

        dim   lngdata(100)   as   long

        dim   fdata(100)   as   single

        dim   i   as   long

 

        select   case   cmbtype.listindex

        case   0:   byttype   =   ppi_i

        case   1:   byttype   =   ppi_q

        case   2:   byttype   =   ppi_m

        case   3:   byttype   =   ppi_v

        case   4:   byttype   =   ppi_s

        case   5:   byttype   =   ppi_sm

        end   select

 

        if   len(txtdata)   >   0   then

                strdata   =   split(txtdata,   "   ")

                if   cmblen.listindex   =   3   then

                        for   i   =   0   to   ubound(strdata)

                                fdata(i)   =   val(strdata(i))

                        next

                        lngret   =   s7_ppi1.writedata(val(txtaddr),   fdata,   ubound(strdata)   +   1,   val(cmblen.listindex),   val(byttype),   cmbno.listindex   +   1)

                else

                        for   i   =   0   to   ubound(strdata)

                                lngdata(i)   =   val(strdata(i))

                        next

                        lngret   =   s7_ppi1.writedata(val(txtaddr),   lngdata,   ubound(strdata)   +   1,   val(cmblen.listindex),   val(byttype),   cmbno.listindex   +   1)

                end   if

 

                if   lngret   =   0   then

                        '

                else

                        txtdata   =   "error"

                end   if

        end   if

        '------------------------------------------------

        exit   sub

        '----------------

toexit:

        msgbox   err.description

end   sub


快速检索

最新资讯
热门点击