我在一个主窗口文件中定义了一个函数,功能大概是通过查询数据库来显示桌子的使用状态,我想在其他窗口中使用这个函数,但是把它改shared后,该函数就没有作用,不但其它窗口中使用不其作用,无法显示图标了,连本窗口中使用都无效了。代码如下:
'定义一个函数用根据使用状态来显示桌子
Public shared function tbreview()
Dim myDS As New DataSet()
Dim sqlstr As String
Dim tbct As Integer
myDS.Clear()
frmmain.ListView1.Clear()
sqlstr = "SELECT * FROM TableInfo"
myDS = GetDataFromDB(sqlstr)
tbct = myDS.Tables(0).Rows.Count
Dim i As Integer
Dim ImgIdx As Integer
For i = 0 To tbct - 1
Select Case Trim(myDS.Tables(0).Rows(i)("当前状态"))
Case Is = "空闲"
ImgIdx = 0
Case Is = "使用中"
ImgIdx = 1
Case Is = "停用"
ImgIdx = 2
Case Is = "被预定"
ImgIdx = 3
Case Is = "脏桌"
ImgIdx = 4
End Select
' Adds a new item with ImageIndex i
frmmain.ListView1.Items.Add("台号" + (i + 1).ToString, ImgIdx)
Next
End function