VB.Net中的隊列類在System.Collections.Generic命名空間中,名字叫Queue,是一個泛型類。
創(chuàng)新互聯(lián)公司主要從事成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)襄垣,10年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220
實例化該類:
Dim myQueue As QueueInt32
myQueue = new QueueInt32();
然后可以通過Queue中的Enqueue和Dequeue函數(shù)進行入隊出隊操作:
With myQueue
.Enqueue(1)
.Enqueue(2)
.Enqueue(3)
.Enqueue(4)
.Enqueue(5)
End With
For i = 0 To 5 Step 1
Console.WriteLine(myQueue.Dequeue())
Next i
顯示結(jié)果:
1
2
3
4
5
GRANT { { SELECT | INSERT | UPDATE | DELETE | REFERENCES | TRIGGER }
[,...] | ALL [ PRIVILEGES ] }
ON [ TABLE ] tablename [, ...]
TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { { USAGE | SELECT | UPDATE }
[,...] | ALL [ PRIVILEGES ] }
ON SEQUENCE sequencename [, ...]
TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { { CREATE | CONNECT | TEMPORARY | TEMP } [,...] | ALL [ PRIVILEGES ] }
ON DATABASE dbname [, ...]
TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { EXECUTE | ALL [ PRIVILEGES ] }
ON FUNCTION funcname ( [ [ argmode ] [ argname ] argtype [, ...] ] ) [, ...]
TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { USAGE | ALL [ PRIVILEGES ] }
ON LANGUAGE langname [, ...]
TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
ON SCHEMA schemaname [, ...]
TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { CREATE | ALL [ PRIVILEGES ] }
ON TABLESPACE tablespacename [, ...]
TO { username | GROUP groupname | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT role [, ...] TO username [, ...] [ WITH ADMIN OPTION ]
希望對你有幫助
用vb.net做的校友錄……(附所有源代碼)
來源:不詳 作者 佚名 點擊數(shù):31 錄入時間:07-12-17 15:21:39
想必大家都上過校友錄吧,里面的功能雖然不是很強大,但是為我們這些畢業(yè)之后各奔西東的學子來說,到真是提供了一個好的聚集點,下面是我用vb.net做的校友錄,當然也不能說是校友錄了,只能說是我們班的學友錄了:)不過只要你掌握了這種編程思想,校友錄就不在話下了。這里我將重點談一下關(guān)于管理員權(quán)限賦予。
以前有這個想法的時候,難就難在管理員身份的賦予上,開始想如果一般用戶在被提升為管理員之后,我可以把他的信息轉(zhuǎn)到另外一個表中,以后登陸的時候先檢查manage表中是否有他就行了,這種辦法我已經(jīng)實現(xiàn)了,是不是有些笨……可是正在我要正式開工的時候,一個想法突然冒了出來,是什么呢?呵呵,就是在數(shù)據(jù)庫中再增加一個字段了如果是第一次注冊就讓這個字段item(int)的值為0,要是被提升之后就update為1,班級創(chuàng)始人呢?當然了,在他申請時付給他一個班級id,然后先判斷班級id為這個已經(jīng)注冊的人信息條數(shù)是否為0,如果是,那么就付給他item=2好了。下面的代碼中,我沒有實現(xiàn)這個功能,因為我做的是班友錄的,當然了,我就是管理員嘍:)
在這里,我使用的是checkboxlist(兩個),一個用來轉(zhuǎn)換數(shù)據(jù)(visibe=fause),一個用來顯示數(shù)據(jù),還有一個checkbox用來寫全部選中的事件。當然了還有兩個按鈕事件,一個是用來提升為管理員的,一個是用來降級為一般用戶的,這兩個按鈕在判斷為一般用戶時
enable都是為fause的,只有當判斷登錄為管理員時才為true。當然了,如果你是班級創(chuàng)始人,是不可能被降級的:)
這里用來顯示信息的我用的是一個datagrid,當判斷為非管理員時,刪除欄的visible將為fause,為管理員的時候,才為true,也就是說只有管理員才可以刪除信息。而不是注冊的用戶是不能發(fā)言的所有的按鈕控件的enable將都為fause。
代碼如下:board.aspx
%@ Page Language="vb" AutoEventWireup="false" Codebehind="boaman.aspx.vb" Inherits="_99re1.boaman"%
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
HTML
HEAD
title/title
meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR"
meta content="Visual Basic 7.0" name="CODE_LANGUAGE"
meta content="javascript" name="vs_defaultClientScript"
meta content="" name="vs_targetSchema"
/HEAD
body background="image/bg.gif" MS_POSITIONING="GridLayout"
form id="Form1" method="post" runat="server"
asp:checkbox id="yourcheck" style="Z-INDEX: 101; LEFT: 84px; POSITION: absolute; TOP: 71px" runat="server" Text="全部選中" AutoPostBack="True" ForeColor="SaddleBrown" Font-Bold="True"/asp:checkbox
asp:button id="Button1" style="Z-INDEX: 102; LEFT: 34px; POSITION: absolute; TOP: 43px" runat="server" Text="提升為管理員" Height="20px" Width="100px" BackColor="Gainsboro" BorderColor="Lavender" BorderWidth="2px" BorderStyle="Outset"/asp:button
asp:button id="Button2" style="Z-INDEX: 103; LEFT: 142px; POSITION: absolute; TOP: 43px" runat="server" Text="降級為一般用戶" Height="20px" Width="100px" BackColor="Gainsboro" BorderColor="Lavender" BorderWidth="2px" BorderStyle="Outset"/asp:button
asp:checkboxlist id="CheckBoxList1" style="Z-INDEX: 104; LEFT: 14px; POSITION: absolute; TOP: 10px" runat="server" Visible="False"/asp:checkboxlist
asp:checkboxlist id="mycheck" style="Z-INDEX: 105; LEFT: 98px; POSITION: absolute; TOP: 99px" runat="server" ForeColor="Navy" Font-Size="X-Small"/asp:checkboxlist
asp:label id="Label1" style="Z-INDEX: 106; LEFT: 82px; POSITION: absolute; TOP: 14px" runat="server" ForeColor="Red" Font-Names="方正姚體"(已注冊用戶)/asp:label
asp:image id="Image1" style="Z-INDEX: 107; LEFT: 260px; POSITION: absolute; TOP: 180px" runat="server" Height="124px" Width="221px" ImageUrl="image/99re1-1.gif"/asp:image
asp:datagrid id="DataGrid1" style="Z-INDEX: 108; LEFT: 250px; POSITION: absolute; TOP: 83px" runat="server" Height="113px" Width="461px" BorderColor="#ffcc66" AutoGenerateColumns="False" HeaderStyle-Font-Size="9" HeaderStyle-HorizontalAlign="Center" HeaderStyle-ForeColor="red" HeaderStyle-Font-Bold="True"
Columns
asp:HyperLinkColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="24" ItemStyle-Font-Size="9" DataNavigateUrlField="stu_id" DataNavigateUrlFormatString="querry.aspx?stu_id={0}" DataTextField="stu_id" HeaderText="學號"/asp:HyperLinkColumn
asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="100" ItemStyle-Font-Size="9" DataField="tel" HeaderText="電話"/asp:BoundColumn
asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="80" ItemStyle-Font-Size="9" DataField="oicq" HeaderText="OICQ"/asp:BoundColumn
asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="140" ItemStyle-Font-Size="9" DataField="email" HeaderText="E-mail"/asp:BoundColumn
asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="60" ItemStyle-Font-Size="9" DataField="point" HeaderText="登錄次數(shù)"/asp:BoundColumn
/Columns
/asp:datagrid
/form
/body
/HTML
下面是codebehind中的內(nèi)容:boaman.asp.vb
Imports System.Data
Imports System.Data.SqlClient
Public Class boaman
Inherits System.Web.UI.Page
Protected WithEvents yourcheck As System.Web.UI.WebControls.CheckBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents CheckBoxList1 As System.Web.UI.WebControls.CheckBoxList
Protected WithEvents mycheck As System.Web.UI.WebControls.CheckBoxList
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
System.Diagnostics.DebuggerStepThrough() Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim conn As SqlConnection = New SqlConnection("server=lixinri;uid=sa;pwd=;database=99re1")
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'////////////////////判斷是否為過客
If Session("stu_id") = "" Then
Button1.Enabled = False : Button2.Enabled = False
'////////////////////調(diào)用check()事件
check()
Else
If Not IsPostBack Then
Dim sql As String = "select * from pwd where stu_id=@stu_id"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))
comm.Parameters("@stu_id").Value = Session("stu_id")
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
While dr.Read
If dr.Item("term") = "0" Then
'///////////////////判斷是否為一般用戶
dr.Close()
Button1.Enabled = False : Button2.Enabled = False
Dim sql_1 As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"
Dim cmd As New SqlCommand(sql_1, conn)
dr = cmd.ExecuteReader
While dr.Read
If dr.Item("term") = "1" Then
mycheck.Items.Add("u" dr.Item("name") "/u" "font color=darkorange(管理員)/font")
ElseIf dr.Item("term") = "2" Then
mycheck.Items.Add("u" dr.Item("name") "/u" "font color=red(班級創(chuàng)始人)font")
Else
mycheck.Items.Add("u" dr.Item("name") "/u")
End If
CheckBoxList1.Items.Add(dr.Item("stu_id"))
End While
Else
'////////////////////判斷是否為管理員
dr.Close()
Button1.Enabled = True : Button2.Enabled = True
Dim sql_1 As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"
Dim cmd As New SqlCommand(sql_1, conn)
dr = cmd.ExecuteReader
While dr.Read
If dr.Item("term") = "1" Then
mycheck.Items.Add("u" dr.Item("name") "/u" "font color=darkorange(管理員)/font")
ElseIf dr.Item("term") = "2" Then
mycheck.Items.Add("u" dr.Item("name") "/u" "font color=red(班級創(chuàng)始人)font")
Else
mycheck.Items.Add("u" dr.Item("name") "/u")
End If
CheckBoxList1.Items.Add(dr.Item("stu_id"))
End While
End If
End While
dr.Close()
'////////////////////////取出數(shù)據(jù),填充dataset
Dim mysql As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"
comm = New SqlCommand(mysql, conn)
Dim mycomm As SqlDataAdapter = New SqlDataAdapter(mysql, conn)
Dim ds As DataSet = New DataSet()
mycomm.Fill(ds, "base")
DataGrid1.DataSource = ds.Tables("base").DefaultView
DataGrid1.DataBind()
End If
End If
End Sub
'///////////////////////書寫check()事件
Sub check()
If Not IsPostBack Then
Dim mysql As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"
Dim comm As New SqlCommand(mysql, conn)
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
While dr.Read
If dr.Item("term") = "1" Then
mycheck.Items.Add("u" dr.Item("name") "/u" "font color=darkorange(管理員)/font")
ElseIf dr.Item("term") = "2" Then
mycheck.Items.Add("u" dr.Item("name") "/u" "font color=red(班級創(chuàng)始人)font")
Else
mycheck.Items.Add("u" dr.Item("name") "/u")
End If
CheckBoxList1.Items.Add(dr.Item("stu_id"))
End While
dr.Close()
Dim mycomm As SqlDataAdapter = New SqlDataAdapter(mysql, conn)
Dim ds As DataSet = New DataSet()
mycomm.Fill(ds, "base")
DataGrid1.DataSource = ds.Tables("base").DefaultView
DataGrid1.DataBind()
End If
End Sub
'/////////////////////填充yourcheck
Private Sub yourcheck_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles yourcheck.CheckedChanged
Dim i As Integer
For i = 0 To mycheck.Items.Count - 1
If yourcheck.Checked Then
mycheck.Items(i).Selected = True
Else
mycheck.Items(i).Selected = False
End If
Next
End Sub
'///////////////////////提升一般用戶為管理員
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
conn.Open()
Dim i As Integer
For i = 0 To mycheck.Items.Count - 1
If mycheck.Items(i).Selected Then
Dim sql_1 As String = "update pwd set term=1 where stu_id=@stu_id and term=0"
Dim comm As SqlCommand = New SqlCommand(sql_1, conn)
comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))
comm.Parameters("@stu_id").Value = CheckBoxList1.Items(i).Text
comm.ExecuteNonQuery()
End If
Next
Response.Redirect("boaman.aspx")
End Sub
'///////////////////////降級管理員為一般用戶
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
conn.Open()
Dim i As Integer
For i = 0 To mycheck.Items.Count - 1
If mycheck.Items(i).Selected Then
Dim sql_1 As String = "update pwd set term=0 where stu_id=@stu_id and term=1"
Dim comm As SqlCommand = New SqlCommand(sql_1, conn)
comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))
comm.Parameters("@stu_id").Value = CheckBoxList1.Items(i).Text
comm.ExecuteNonQuery()
End If
Next
Response.Redirect("boaman.aspx")
End Sub
End Class
當然了,這里面還有好多不足的地方,懇求高手批評指正。
校友錄還有一些其它的功能就很簡單了,這里就不再探討了。
給你個udp多播例子,廣播不是很清楚,呵呵
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Inherits System.Windows.Forms.Form
Dim port As String
Dim ipadd As String
Dim ipend As IPEndPoint
Dim sendudp As New UdpClient()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim ipadress As IPAddress
ipadress = IPAddress.Parse(TextBox1.Text)
'sendport = Int32.Parse(TextBox2.Text)
'ipend = New IPEndPoint(ipadress, sendport)
Try
sendudp.JoinMulticastGroup(ipadress)
MessageBox.Show("啟動完成!")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
下面這段代碼,是我用來計算每個月存500元進銀行,連續(xù)30年,最后連本帶利能有多少錢。這里面涉及復利計算。界面中右邊的文本框用來輸出每一次計算的結(jié)果。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
? Dim nianxian As Integer '年限變量
? Dim dingcun As Integer '定存變量
? Dim fuli_big As Long '大復利
? Dim fuli_small As Long '小復利
? Dim i As Integer '循環(huán)變量
? Dim DATAstring As String '數(shù)據(jù)字符串
? nianxian = Val(年限_TextBox.Text)
? dingcun = Val(定存_TextBox.Text)
? DATAstring = ""
? For i = 1 To nianxian
? ? ? fuli_small = dingcun * (1 + 0.1875)
? ? ? dingcun = fuli_small
? ? ? fuli_big = fuli_big + fuli_small
? ? ? DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_big) + Chr(13) + Chr(10)
? ? ? 'DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_small) + Chr(13) + Chr(10)
? Next
? 'fuli_big = fuli_small
? TextBox1.Text = DATAstring
? 結(jié)果_TextBox.Text = Str(fuli_big) + "元"
End Sub
得說明是什么型號的PLC啊,串口還是網(wǎng)口,VB6還是VB.NET?
算了,寫段代碼,VB.NET與Q系列以太網(wǎng)通訊的:
Imports?System.Net
Imports?System.Runtime.InteropServices
Public?Class?Form1
Dim?Handle1?As?Int32
Dim?EntLink1?As?Boolean
Dim?ScanCount1?As?Long
Dim?PLC?As?New?EntQsPlc_Asc.PlcClient'EntQsPlc_ASC.DLL是Q系列以太網(wǎng)通訊組件
Public?Declare?Function?timeGetTime?Lib?"winmm.dll"?()?As?UInt32
Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load
Me.CenterToScreen()
cmbReadMry.Items.Clear()
cmbReadMry.Items.Add("X")
cmbReadMry.Items.Add("Y")
cmbReadMry.Items.Add("M")
cmbReadMry.Items.Add("D")
cmbReadMry.Items.Add("R")
cmbReadMry.Items.Add("Z")
'
cmbWriteMry.Items.Clear()
cmbWriteMry.Items.Add("X")
cmbWriteMry.Items.Add("Y")
cmbWriteMry.Items.Add("M")
cmbWriteMry.Items.Add("D")
cmbWriteMry.Items.Add("R")
cmbWriteMry.Items.Add("Z")
'
cmbBitMry.Items.Clear()
cmbBitMry.Items.Add("X")
cmbBitMry.Items.Add("Y")
cmbBitMry.Items.Add("M")
'
cmbReadType.Items.Clear()
cmbReadType.Items.Add("INT16")
cmbReadType.Items.Add("UINT16")
cmbReadType.Items.Add("DINT32")
cmbReadType.Items.Add("HEX32")
cmbReadType.Items.Add("REAL32")
cmbReadType.Items.Add("BIN16")
'
cmbWriteType.Items.Clear()
cmbWriteType.Items.Add("INT16")
cmbWriteType.Items.Add("UINT16")
cmbWriteType.Items.Add("DINT32")
cmbWriteType.Items.Add("HEX32")
cmbWriteType.Items.Add("REAL32")
cmbWriteType.Items.Add("BIN16")
cmbReadMry.SelectedIndex?=?3
cmbWriteMry.SelectedIndex?=?3
cmbBitMry.SelectedIndex?=?2
cmbReadType.SelectedIndex?=?0
cmbWriteType.SelectedIndex?=?0
lstRead.Items.Clear()
txtWrite.Text?=?""
'
cmbCmdType.SelectedIndex?=?0
End?Sub
Private?Sub?butLink_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butLink.Click
Dim?re?As?Short
Dim?restr?As?String?=?""
re?=?PLC.EntLink(Trim(txtLocalIP.Text),?Val(txtLocalPort.Text),?Trim(txtRemoteIP.Text),?Val(txtRemotePort.Text),?"DEMO",?Handle1,?1000,?CBool(cmbCmdType.SelectedIndex))
txtReLink.Text?=?re.ToString
If?re?=?0?Then
EntLink1?=?True
MsgBox("PLC聯(lián)接成功!?")
Else
EntLink1?=?False
MsgBox("PLC聯(lián)接失敗:?"??restr)
End?If
End?Sub???????????
Private?Sub?butClose_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butClose.Click
Dim?re?As?Short
If?Not?EntLink1?Then
MsgBox("還未與PLC建立聯(lián)接!")
Exit?Sub
End?If
re?=?PLC.DeLink(Handle1)
txtReClose.Text?=?re.ToString
End?Sub
Private?Sub?butRead_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butRead.Click
Dim?re?As?Short
Dim?i?As?Short
Dim?RD()?As?Object
ReDim?RD(Val(txtReadCnt.Text?-?1))
If?Not?EntLink1?Then
MsgBox("還未與PLC建立聯(lián)接!")
'?Exit?Sub
End?If
Dim?mry?As?EntQsPlc_Asc.PlcClient.PlcMemory?=?cmbReadMry.SelectedIndex?+?1
Dim?typ?As?EntQsPlc_Asc.PlcClient.DataType?=?cmbReadType.SelectedIndex?+?1
re?=?PLC.CmdRead(Handle1,?mry,?typ,?CInt(txtReadAdd.Text),?CUShort(txtReadCnt.Text),?RD)
txtReRead.Text?=?re.ToString
lstRead.Items.Clear()
For?i?=?0?To?UBound(RD)?Step?1
If?Not?IsNothing(RD(i))?Then?lstRead.Items.Add(RD(i))
Next?i
If?re??0?Then
Timer1.Enabled?=?False
butScan.Text?=?"Cycle?R/W"
End?If
End?Sub
Private?Sub?butWrite_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butWrite.Click
Dim?re?As?Short
Dim?i?As?Short
Dim?temp()?As?String
Dim?WD()?As?Object
If?Not?EntLink1?Then
MsgBox("還未與PLC建立聯(lián)接!")
Exit?Sub
End?If
ReDim?WD(Val(txtWriteCnt.Text)?-?1)
temp?=?Split(txtWrite.Text,?vbCrLf)
For?i?=?0?To?UBound(WD)?Step?1
If?i??UBound(temp)?Then
WD(i)?=?0
Else
WD(i)?=?Trim(temp(i))
End?If
Next?i
Dim?mry?As?EntQsPlc_Asc.PlcClient.PlcMemory?=?cmbWriteMry.SelectedIndex?+?1
Dim?typ?As?EntQsPlc_Asc.PlcClient.DataType?=?cmbWriteType.SelectedIndex?+?1
re?=?PLC.CmdWrite(Handle1,?mry,?typ,?CInt(txtWriteAdd.Text),?CUShort(txtWriteCnt.Text),?WD)
txtReWrite.Text?=?re.ToString
If?re??0?Then
Timer1.Enabled?=?False
butScan.Text?=?"Cycle?R/W"
End?If
End?Sub
Private?Sub?butScan_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butScan.Click
If?Not?EntLink1?Then
MsgBox("還未與PLC建立聯(lián)接!")
Exit?Sub
End?If
Timer1.Enabled?=?Not?Timer1.Enabled
If?Timer1.Enabled?Then
ScanCount1?=?0
butScan.Text?=?"Stop?R/W"
Else
butScan.Text?=?"Cycle?R/W"
End?If
End?Sub
Private?Sub?Timer1_Tick(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Timer1.Tick
Timer1.Enabled?=?False
Dim?tim?As?Integer?=?timeGetTime
If?Not?EntLink1?Then
MsgBox("還未與PLC建立聯(lián)接!")
Exit?Sub
End?If
'
Call?butRead_Click(Nothing,?Nothing)
Call?butWrite_Click(Nothing,?Nothing)
'
If?(Val(txtReRead.Text)??0)?Or?(Val(txtReWrite.Text)??0)?Then
butScan.Text?=?"Cycle?R/W"
Exit?Sub
Else
ScanCount1?+=?1
txtScanCnt.Text?=?ScanCount1
txtScanPrd.Text?=?(timeGetTime?-?tim)??"ms"
End?If
Timer1.Enabled?=?True
End?Sub
Private?Sub?butBitTest_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butBitTest.Click
If?Not?EntLink1?Then
MsgBox("還未與PLC建立聯(lián)接!")
Exit?Sub
End?If
Dim?rd?As?Boolean
Dim?re?As?Short
Dim?mry?As?EntQsPlc_Asc.PlcClient.PlcMemory?=?cmbBitMry.SelectedIndex?+?1
re?=?PLC.Bit_Test(Handle1,?mry,?CUShort(txtBitAdd.Text),?rd)
txtBitTest.Text?=?rd
txtReBit.Text?=?re
End?Sub
Private?Sub?butBitSet_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butBitSet.Click
If?Not?EntLink1?Then
MsgBox("還未與PLC建立聯(lián)接!")
Exit?Sub
End?If
Dim?re?As?Short
re?=?PLC.Bit_Set(Handle1,?cmbBitMry.SelectedIndex?+?1,?Val(txtBitAdd.Text))
txtReBit.Text?=?re
End?Sub
Private?Sub?butBitRst_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butBitRst.Click
If?Not?EntLink1?Then
MsgBox("還未與PLC建立聯(lián)接!")
Exit?Sub
End?If
Dim?re?As?Short
re?=?PLC.Bit_Reset(Handle1,?cmbBitMry.SelectedIndex?+?1,?Val(txtBitAdd.Text))
txtReBit.Text?=?re
End?Sub
End?Class