- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 1# yoya
但是當我把它改為變數之後,系統就讀不到我的下單字串。
可以啊,- Option Explicit
- Sub Ex()
- Dim A As String, B As Boolean
- '程式中使用函數 有參數給參數,沒參數不用給
- Sheet1.Cells(1, 2) = "S"
- A = GetOrderText("第一個參數OrderStock的字串", "第二個參數OrderPrice的字串")
- B = Test_Function
- MsgBox A
- MsgBox B
- Sheet1.Cells(1, 2) = "s"
- MsgBox GetOrderText("第一個參數OrderStock的字串", "第二個參數OrderPrice的字串")
- MsgBox Test_Function
- End Sub
- Function Test_Function() As Boolean
- If Sheet1.Cells(1, 2) = "S" Then Test_Function = True
- End Function
- Public Function GetOrderText(OrderStock As String, OrderPrice As String)
- GetOrderText = "GetOrderText ???"
- If Sheet1.Cells(1, 2) = "S" Then
- GetOrderText = "Account=" & Sheet1.Cells(3, 2) & ",ProductID=" & OrderStock & ",TradeType=" & Sheet1.Cells(6, 2) & ", TradeKind=" & Sheet1.Cells(7, 2) & ", OrderType=" & Sheet1.Cells(8, 2) & ", BuySell=" & Sheet1.Cells(9, 2) & ", Qty=" & Sheet1.Cells(10, 2) & ", Price=" & OrderPrice & ", OrderNo=" & Sheet1.Cells(12, 2) & ", TradeDate=" & Sheet1.Cells(13, 2) & ", BasketNo=" & Sheet1.Cells(14, 2)
- End If
- End Function
複製代碼 |
|