主题:求助啊,各位老师不吝指教哦
大家帮我看看,这个将堆垛机的库位坐标转化成列、层的程序对不对噢,如果相应库位有货物就在MSHflexgrid对应位置显示一张图片
数据库表(warehousestockdetail)
ID WarePosCode MaterielCode Materielnum
11 pos133 cs 1
ID WarePosCode materielcode
1 pos102 12456 pos102 第二层第一列
2 pos103 cs pos103 第三层第一列
3 pos106 cs pos106 第一层第一列(每五个库位为一列)
Public Sub qianzhuobiao()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim connstr As String
Dim sql As String
Dim row As Integer
Dim col As Integer
Dim pos As String
connstr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID =sa;Initial Catalog=PT_AS_DB;Data Source=ouyang-c19a8722."
conn.ConnectionString = connstr
conn.Open connstr
rs.CursorLocation = adUseClient
sql = "select * from WarehouseStockDetail "
rs.Open sql, conn, adOpenDynamic, adLockPessimistic '连接数据库
pos = rs.Fields(1)
i = Val(Right$(pos, 3))
If i >= 101 And i <= 150 Then
For i = 101 To 150
x = i \ 5
y = i Mod 5
If x = 20 And y = 1 Then row = 1: col = 1
If x = 20 And y = 2 Then row = 2: col = 1
If x = 20 And y = 3 Then row = 3: col = 1
If x = 20 And y = 4 Then row = 4: col = 1
If x = 21 And y = 0 Then row = 5: col = 1
If x = 21 And y = 1 Then row = 1: col = 2
If x = 21 And y = 2 Then row = 2: col = 2
If x = 21 And y = 3 Then row = 3: col = 2
If x = 21 And y = 4 Then row = 4: col = 2
If x = 22 And y = 0 Then row = 5: col = 2
下面是将在mshflexgrid上显示图片代码,
If rs.RecordCount > 0 Then
rs.MoveFirst
rs.MoveLast
For i = 1 To rs.RecordCount
qianzhuobiao
MSHFlexGrid1.row = 6 - row
MSHFlexGrid1.col = col
If rs.Fields(2) = "cs" Then Set MSHFlexGrid1.CellPicture = LoadPicture("D:\VB工程\工程2\res\面包.jpg")
rs.MoveFirst
rs.MoveNext
rs.MoveLast
Next i
End If
End Sub
帮我看看红色代码应该怎么改了