標題:
美化提示訊息
[打印本頁]
作者:
myleoyes
時間:
2014-3-30 22:04
標題:
美化提示訊息
各位前輩你們好!!
問題如附檔說明
請知道的前輩,不吝賜教謝謝再三!!
作者:
owen06
時間:
2014-3-31 09:15
回復
1#
myleoyes
用 & chr(10) & 可以讓msgbox裡的文字自動換行
Sub Msg()
MsgBox ("") & Sheet3.[B1].Text & ":" & Chr(10) & _
" #投資額" & Sheet3.[C1].Text & Chr(10) & _
" #配息" & Sheet3.[M1].Text & Chr(10) & _
" #損益" & Sheet3.[N1].Text & Chr(10) & _
" #報酬率" & Sheet3.[O1].Text & Chr(10) & _
" #管理費" & Sheet3.[AC1].Text & Chr(10) & _
" #手續費" & Sheet3.[G1].Text & Chr(10) & _
Sheet4.[A1].Text & ":" & Chr(10) & _
" #投資額" & Sheet4.[B2].Text & Chr(10) & _
" #配息" & Sheet4.[i8].Text & Chr(10) & _
" #損益" & Sheet4.[E4].Text & Chr(10) & _
" #報酬率" & Sheet4.[F4].Text & Chr(10) & _
" #管理費" & Sheet4.[H7].Text & Chr(10) & _
" #手續費" & Sheet4.[F2].Text
End Sub
複製代碼
作者:
myleoyes
時間:
2014-3-31 21:51
回復
2#
owen06
前輩!謝謝!!
有一問題再請教小弟想加入一個時間
讓MsgBox自動關閉而非手動關閉
Application.OnTime Now + TimeValue("00:00:05"), "自動關閉"
請知道的前輩,不吝賜教謝謝再三!!
作者:
GBKEE
時間:
2014-4-1 06:26
回復
3#
myleoyes
Sub MsgBox_Wait()
Dim WshShell, BtnCode
Set WshShell = CreateObject("WScript.Shell")
BtnCode = WshShell.popup("等待2秒不按我就自動關閉?", 2, "測試:", 4 + 16)
Select Case BtnCode
Case 6
BtnCode = "你按了""是""." 'MsgBox "你按了""是""."
Case 7
BtnCode = "你按了""否""." 'MsgBox "你按了""否""."
Case -1
BtnCode = "沒有按任何鍵"
End Select
BtnCode = WshShell.popup(BtnCode, 2, "測試完畢", 1)
End Sub
複製代碼
作者:
myleoyes
時間:
2014-4-1 22:48
回復
4#
GBKEE
良師!謝謝!
另有一問題如附檔說明
請不吝再賜教辛苦囉謝謝再三!!
作者:
GBKEE
時間:
2014-4-2 06:31
回復
5#
myleoyes
Option Explicit
Sub Msg()
Dim WshShell As Object, BtnCode As String, A As String, B As String, i As Integer, ii As Integer
'變數的設定最好置於程式碼的前端以便程式的偵錯
Set WshShell = CreateObject("WScript.Shell")
A = Sheet2.[D1].FormulaR1C1
B = Sheet2.[E1].FormulaR1C1 '=-33+20+5+543+22-60+300-99-96-33+20+5
For i = 3 To Len(A) '公式的開頭會是 =- 所以 i 從 3 開始
If Not Mid(A, i, 1) Like "[0-9]" Then ii = ii + 1 '不是數字加 1
If ii = 2 Then A = Mid(A, 2, i - 2): Exit For
Next
ii = 0 '歸零
For i = 3 To Len(B)
If Not Mid(B, i, 1) Like "[0-9]" Then ii = ii + 1
If ii = 2 Then B = Mid(B, 2, i - 2): Exit For
Next
BtnCode = " 此次作多損益" & A & Chr(10) & " 此次作空損益" & B
BtnCode = WshShell.popup(BtnCode, 2, "損益對帳訊息!!", 0)
End Sub
複製代碼
作者:
myleoyes
時間:
2014-4-2 21:22
回復
6#
GBKEE
良師!辛苦囉謝謝再三!!
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)