51Testing软件测试论坛

标题: 这堆东西有搞头没? [打印本页]

作者: Ganve_001    时间: 2011-8-17 17:46
标题: 这堆东西有搞头没?
本帖最后由 Ganve_001 于 2011-8-17 17:47 编辑

据说万物皆有规律。。我每天根据这个去买一注。。会不会瞎猫碰到死老鼠???
当然写的比较乱。。优化和改造地方很多

  1. Dim BlueNumber,RedNumber
  2. Dim objExcel,objWorkBook,objWorkSheet,ColNo,Col,addRow
  3. Dim Times,Com,i,j
  4. Dim DabouleBall(7)
  5. Dim FilePath
  6. For Times  =1 to 7
  7.   If Times< 7 Then
  8.     BlueNumber  = Randomnumber(1,33)
  9.       For Com =1 to 6
  10.         If DabouleBall(Com) = BlueNumber Then
  11.           Times = Times -1
  12.           Exit For
  13.         Else
  14.           'Keep Doing
  15.         End If
  16.         If Com = 6 Then
  17.           DabouleBall(Times) = BlueNumber
  18.         End If
  19.       Next
  20.   ElseIf Times = 7 Then
  21.     RedNumber = Randomnumber(1,16)
  22.     DabouleBall(Times) = RedNumber
  23.   End If
  24. Next
  25. For i = 1 to 5
  26.   For j = i +1 to 6
  27.     If DabouleBall(i) >DabouleBall(j) Then
  28.        Trans= DabouleBall(i)
  29.        DabouleBall(i) = DabouleBall(j)
  30.        DabouleBall(j)= Trans
  31.     End If
  32.   Next
  33. Next
  34. FilePath = "E:\DoubleBall.xlsx"
  35. Set Fso  = CreateObject("Scripting.FileSystemObject")
  36. If Fso.FileExists(FilePath) = False Then
  37.   Set objExcel  = CreateObject("Excel.Application")
  38.   Set objWorkBook = objExcel.Workbooks.Add
  39.   Set objWorkSheet = objWorkBook.ActiveSheet
  40.   For ColNo = 0 to 7
  41.     Col = chr(65+ColNo)
  42.     If ColNo  = 0 Then
  43.       objWorkSheet.Range(Col & 1) ="Date"
  44.     ElseIf  ColNo=7 Then
  45.       objWorkSheet.Range(Col & 1) ="RedNo."
  46.     Else
  47.       objWorkSheet.Range(Col & 1) ="BlueNo."
  48.     End If
  49.   Next
  50.   objWorkBook.SaveAs(FilePath)
  51.   objExcel.Workbooks.Close
  52.   objExcel.Quit
  53.   Set objWorkBook = Nothing
  54.   Set objExcel = Nothing
  55. Else
  56.   Set objExcel  = CreateObject("Excel.Application")
  57.   'objExcel.Visible = True
  58.   Set objWorkBook = objExcel.Workbooks.Open(FilePath)
  59.   Set objWorkSheet = objWorkBook.ActiveSheet
  60.   Set objWorkRange =  objWorkBook.ActiveSheet.UsedRange
  61.   addRow = objWorkRange.Rows.count+1
  62.   For   ColNo = 0  to 7
  63.     Col = chr(65+ColNo)
  64.     If ColNo  = 0 Then
  65.       objWorkSheet.Range(Col & addRow) =Date
  66.       'objWorkSheet.Range(Col & addRow).Interior.colorindex=4
  67.     Else
  68.       objWorkSheet.Range(Col & addRow)  = DabouleBall(ColNo)
  69.     End If
  70.   Next
  71.   objWorkBook.Save
  72.   objExcel.Workbooks.Close
  73.   objExcel.Quit
  74.   Set objWorkRange = Nothing
  75.   Set objWorkSheet =Nothing
  76.   Set  objWorkBook =Nothing
  77.   Set objExcel =Nothing
  78. End If
复制代码

作者: lyscser    时间: 2011-8-17 19:06
完全没搞头……坐等5亿归来




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2