| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 248 人关注过本帖
标题:大家帮我看看,
只看楼主 加入收藏
ouyangzhi520
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2012-12-3
结帖率:100%
收藏
 问题点数:0 回复次数:0 
大家帮我看看,
大家帮我看看,这个将堆垛机的库位坐标转化成列、层的程序对不对噢,如果相应库位有货物就在MSHflexgrid对应位置显示一张图片
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
帮我看看红色代码应该怎么改了
2012-12-09 11:47
快速回复:大家帮我看看,
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028775 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved