Attribute VB_Name = "Module1"
Public stremu As String   '沒事我亂設的
Public setting As String    'y通訊設定
Public comport As Integer     '傳輸埠
Public baudrate As String  '鮑率
Public parity As String '傳輸協定
Public dcode As Byte     'command type
Public clrdisplay As String
 '此模組必須搭配msg.frm使用
 Public return_String As String
 Public retn As Integer
 Public MessageFlag As Boolean
Public Function Mesg(Message As String, YesorNo As Integer, Title As String) As Long
Dim a: msg.Text1.Enabled = False: msg.Text1.Visible = False
If MessageFlag = True Then Exit Function
MessageFlag = True
mlen = Len(Message)

If mlen < 36 Then
msg.Height = 1425: msg.Width = 3005
msg.Label1.Height = 641.5: msg.Label1.Width = 2050.57: msg.Label1.Top = 90: msg.Label1.Left = 184
msg.Command1.Top = 610: msg.Command1.Left = 61
msg.Command2.Top = 610: msg.Command2.Left = 787
msg.Command3.Top = 610: msg.Command3.Left = 1510
End If

If mlen > 51 Then
msg.Label1.Height = 1070
msg.Command1.Top = 1150: msg.Command2.Top = 1150: msg.Command3.Top = 1150
End If

If mlen > 28 And mlen < 36 Then
msg.Label1.Top = 10
msg.Command2.Top = 630: msg.Command1.Top = 630: msg.Command1.Top = 630
End If

msg.Label1.Caption = Message
msg.Caption = Title

Select Case YesorNo
Case 1
msg.Command1.Caption = "Yes"
msg.Command1.Left = msg.Command2.Left
msg.Command2.Visible = False
msg.Command3.Visible = False
Case 2
msg.Command1.Caption = "Yes"
msg.Command1.Left = (msg.Command1.Left + msg.Command2.Left) / 2.6
msg.Command2.Caption = "No"
msg.Command2.Left = (msg.Command2.Left + msg.Command3.Left) / 1.8
msg.Command3.Visible = False
Case 3
msg.Command1.Caption = "Yes"
msg.Command2.Caption = "No"
msg.Command3.Caption = "Cancel"
Case 4
msg.Command1.Caption = "Ok"
msg.Command1.Left = msg.Command2.Left
msg.Command2.Visible = False
msg.Command3.Visible = False
Case 5
msg.Command1.Caption = "Ok"
msg.Command1.Left = (msg.Command1.Left + msg.Command2.Left) / 2.6
msg.Command2.Caption = "Abort"
msg.Command2.Left = (msg.Command2.Left + msg.Command3.Left) / 1.8
msg.Command3.Visible = False
Case 6
msg.Command1.Caption = "Ok"
msg.Command2.Caption = "Abort"
msg.Command3.Caption = "Retry"
End Select
msg.Show vbModal
Mesg = retn
MessageFlag = False
End Function



Public Function inpbox(Message As String, Title As String, txt As String) As String
Dim a
If MessageFlag = True Then Exit Function
MessageFlag = True
mlen = Len(Message)

msg.Label1.Alignment = 0
'msg.Label1.AutoSize = True

msg.Label1.Height = 1070
msg.Command1.Top = 80: msg.Command2.Top = 510: msg.Command3.Top = 1150
msg.Command1.Left = 3000: msg.Command2.Left = 3000
msg.Label1.Width = 2403: msg.Label1.Height = 1255: msg.Label1.Top = 120: msg.Label1.Left = 184
msg.Width = 5000: msg.Text1.Width = 3550: msg.Text1.TabIndex = 0

msg.Label1.Caption = Message
msg.Caption = Title

msg.Command1.Caption = "Ok"

msg.Command2.Caption = "Cancel"

msg.Command3.Visible = False
If Len(txt) <> 0 Then
msg.Text1.Text = txt
Else
msg.Text1.Text = "": msg.Text1.Height = 330
End If
'If mode = 2 Then msg.Text1.Text = Format(Return_string, "##-##-##")

msg.Show vbModal
 inpbox = return_String
 If retn = 13 Then inpbox = ""
MessageFlag = False
End Function
