小弟最近才学VB编程试写了一个数据库的小程序 其中我想文本里的东西比如调用C:\test.txt里的ID码 可是只能调用1个ID我要想调用两个就不可以在PB里ID码之间用逗号各开就行了可是 现在在文本里用逗号各开总是提示无效数字 代码如下: Private Sub Command1_Click() Dim FileNo As Long, son As String, Rst As New Recordset, StrSql As String FileNo = FreeFile Open "C:\test.txt" For Input As #FileNo son = StrConv(InputB(LOF(FileNo), #FileNo), vbUnicode) Close #FileNo Command1.Enabled = False StrSql = " SELECT sum((RESA_SA_DTL.GOODSQTY)*(select pub_goods_price.price from pub_goods_price where pub_goods_price.priceid=3 and pub_goods_price.goodsid=RESA_SA_DTL.GOODSID and RESA_SA_DTL.GOODSID in ('" & son & "')))" _ & "FROM RESA_SA_DOC,RESA_SA_DTL " _ & "Where RESA_SA_DTL.RSAID = RESA_SA_DOC.RSAID and to_char(RESA_SA_DOC.CREDATE,'yyyy-mm-dd') between '" & Format(DateSpace.StartDate, "yyyy-mm-dd") & "' and '" & Format(DateSpace.EndDate, "yyyy-mm-dd") & "' " Rst.Open StrSql, AdoCn, adOpenForwardOnly, adLockReadOnly Set xian.DataSource = Rst Set Rst = Nothing Formatxian Command1.Enabled = True End Sub
Sub Formatxian() On Error GoTo 1 With xian .FormatString = "ID|uuuu|uuuu" .ColWidth(0) = 3000 .ColWidth(1) = 1400 .ColWidth(2) = 1400 For i = 0 To 2 .ColAlignment(i) = flexAlignLeftCenter .FixedAlignment(i) = flexAlignCenterCenter Next i .Row = .Rows - 1 .ColSel = 2 .TopRow = .Row End With 1: End Sub