⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 long.frm

📁 与瑞得850的rs232通讯
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   5160
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   6840
      Width           =   1095
   End
   Begin VB.Label Label9 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "在测量前请确保您已经将仪器调平且两仪器通讯参数相同"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   240
      Left            =   240
      TabIndex        =   18
      Top             =   360
      Width           =   6375
   End
   Begin VB.Menu File 
      Caption         =   "文件"
      Begin VB.Menu Quit 
         Caption         =   "退出"
      End
   End
   Begin VB.Menu Pro 
      Caption         =   "通讯"
      Begin VB.Menu ProSetting 
         Caption         =   "通讯参数"
      End
   End
   Begin VB.Menu Help 
      Caption         =   "帮助"
      Begin VB.Menu About 
         Caption         =   "关于 北京飞鹿"
      End
   End
End
Attribute VB_Name = "frmlong"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub About_Click()
    Dim Style, Title, Response As String
    Style = vbOKOnly + vbInformation + vbDefaultButton2
    Title = "关于 北京飞鹿体育用品有限公司"
    Response = MsgBox("北京飞鹿体育用品有限公司 1.0.0" + vbCrLf + "", Style, Title)
End Sub

Private Sub clean_Click()

Startx1.Caption = ""
Starty1.Caption = ""
Startx2.Caption = ""
Starty2.Caption = ""
Endx1.Caption = ""
Endy1.Caption = ""
Text1.Text = ""
Result.Caption = ""
frmmath.Text.Text = ""
End1.Enabled = False
Record.Enabled = False

End Sub

Private Sub close_Click()

frmmath.Text.Text = ""
Unload Me

End Sub

Private Sub end1_Click()

    If Startx1.Caption = Startx2.Caption And Starty1.Caption = Starty2.Caption Then
        MsgBox "起点重叠,请重新测量"
        Exit Sub
    End If

    If Starty1.Caption = "" Or Startx1.Caption = "" Then
        MsgBox "缺少起点数据"    '当数据太小时,会认为数据为0,导致出错
        Exit Sub
    End If

    Dim B3, V3, S3 As Single
    Dim DS3, X1, Y1, X2, Y2, X3, Y3, D1, D2, D3, D4, Temp As Single
     
    Start1.Enabled = False
    Start2.Enabled = False
    End1.Enabled = False
    Record.Enabled = False
    Endx1.Caption = ""
    Endy1.Caption = ""
    Result.Caption = ""
    
    Call Separatedata(B3, V3, S3)
    
    Start1.Enabled = True
    Start2.Enabled = True
    End1.Enabled = True
    
    If S3 = 0 Then
        Exit Sub
    End If
    
    DS3 = S3 * Sin(V3)
    X3 = DS3 * Cos(B3)
    Y3 = DS3 * Sin(B3)

    Endx1.Caption = Format(X3, "0.000")
    Endy1.Caption = Format(Y3, "0.000")
    
    '计算
    X1 = Longx1
    Y1 = Longy1
    X2 = Longx2
    Y2 = Longy2
    
    D1 = Sqr((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2))
    D2 = Sqr((X2 - X3) * (X2 - X3) + (Y2 - Y3) * (Y2 - Y3))
    D3 = Sqr((X1 - X3) * (X1 - X3) + (Y1 - Y3) * (Y1 - Y3))
    D4 = (D1 + D2 + D3) / 2#
    
    Temp = 2# * Sqr(D4 * (D4 - D1) * (D4 - D2) * (D4 - D3)) / D1
    Result.Caption = Format(Temp, "0.000")

End Sub



Private Sub Form_Load()
    Frame1.BackColor = Me.BackColor
    Frame2.BackColor = Me.BackColor
    Frame3.BackColor = Me.BackColor
    Frame4.BackColor = Me.BackColor
    Label1.BackColor = Me.BackColor
    Label2.BackColor = Me.BackColor
    Label3.BackColor = Me.BackColor
    Label4.BackColor = Me.BackColor
    Label5.BackColor = Me.BackColor
    Label6.BackColor = Me.BackColor
    Label7.BackColor = Me.BackColor
    Label8.BackColor = Me.BackColor
    
    Left = (Screen.Width - Me.Width) \ 2
    Top = (Screen.Height - Me.Height) \ 2   '窗口居中
    
    Startx1.Caption = Format(Longx1, "0.000")
    Starty1.Caption = Format(Longy1, "0.000")
    Startx2.Caption = Format(Longx2, "0.000")
    Starty2.Caption = Format(Longy2, "0.000")
    Rs232 = "" '进入窗口,数据清零
    
    On Error Resume Next    '忽略错误继续执行
    If frmmath.MSComm1.PortOpen = False Then frmmath.MSComm1.PortOpen = True
    If Err Then '出错的话,弹出错误对话框
        MsgBox Error$ + ",请确认线路已连接并设置正确通讯参数", 48
        Exit Sub
    End If

End Sub


Private Sub Form_Unload(Cancel As Integer)
    If frmmath.MSComm1.PortOpen = True Then frmmath.MSComm1.PortOpen = False
End Sub

Private Sub ProSetting_Click()
    frmProperties.Show vbModal
End Sub

Private Sub Quit_Click()
    Unload Me
End Sub

Private Sub Record_Click()
    Dim Temp As String        'a用于存储数据
    
    If Text1.Text = "" Or Result.Caption = "" Then
        MsgBox "缺少运动员号或成绩"
        Exit Sub
    End If
    
    Temp = App.Path + "\" + Trim(Str(Year(Date))) + Trim(Str(Month(Date))) + Trim(Str(Day(Date))) + "跳远成绩.txt"
    If Dir(Temp) = "" Then
         Open Trim(Temp) For Append As #1
         Print #1, "运动员号" + vbTab + "成绩"
         Close
    End If
        Open Trim(Temp) For Append As #1
          Print #1, Text1.Text + vbTab + Result.Caption
         Close
    FileCopy Temp, App.Path + "\" + Trim(Str(Year(Date))) + Trim(Str(Month(Date))) + Trim(Str(Day(Date))) + "跳远成绩.xls"
    '另存为xls文件
    
    Endx1.Caption = ""
    Endy1.Caption = ""
    Text1.Text = ""
    Result.Caption = ""
    Longx1 = ""
    Longy1 = ""
    Longx2 = ""
    Longy2 = ""
    Rs232 = ""
    '数据都清零
    Record.Enabled = False
    '按钮去除使能
End Sub

Private Sub Result_Change()
    If Text1.Text <> "" Then Record.Enabled = True
End Sub

Private Sub start1_Click()
    Dim B1, V1, S1 As Single
    Dim Ds1, X1, Y1 As Single
    
    Startx1.Caption = ""
    Starty1.Caption = ""
    Endx1.Caption = ""
    Endy1.Caption = ""
    Result.Caption = ""
    Start1.Enabled = False
    Start2.Enabled = False
    End1.Enabled = False
    Record.Enabled = False
     
    Call Separatedata(B1, V1, S1)
    
    Start1.Enabled = True
    Start2.Enabled = True
    
    If S1 = 0 Then
        Exit Sub
    End If
        
    Ds1 = S1 * Sin(V1)
    X1 = Ds1 * Cos(B1)
    Y1 = Ds1 * Sin(B1)
    
    Longx1 = X1
    Longy1 = Y1
    Startx1.Caption = Format(X1, "0.000")
    'format用于格式化字符串,0.###用于用于保留3位小数,并在不足1的数字前面加0
    Starty1.Caption = Format(Y1, "0.000")

    If Startx2.Caption <> "" Then End1.Enabled = True
    
End Sub

Private Sub start2_Click()
    Dim B2, V2, S2 As Single
    Dim Ds2, X2, Y2 As Single
    
    Startx2.Caption = ""
    Starty2.Caption = ""
    Endx1.Caption = ""
    Endy1.Caption = ""
    Result.Caption = ""
    Start1.Enabled = False
    Start2.Enabled = False
    End1.Enabled = False
    Record.Enabled = False
    
    Call Separatedata(B2, V2, S2)
    
    Start1.Enabled = True
    Start2.Enabled = True
           
    If S2 = 0 Then
        Exit Sub
    End If
    
    Ds2 = S2 * Sin(V2)
    X2 = Ds2 * Cos(B2)
    Y2 = Ds2 * Sin(B2)
    
    Longx2 = X2
    Longy2 = Y2
    
    Startx2.Caption = Format(X2, "0.000")
    'format用于格式化字符串,0.###用于用于保留3位小数,并在不足1的数字前面加0
    Starty2.Caption = Format(Y2, "0.000")
        
    If Startx1.Caption <> "" Then End1.Enabled = True
    
End Sub

Private Sub Startx1_Change()
    If Startx2.Caption <> "" Then End1.Enabled = True
End Sub

Private Sub Startx2_Change()
    If Startx1.Caption <> "" Then End1.Enabled = True
End Sub


Private Sub Text1_Change()
    If Result.Caption <> "" Then Record.Enabled = True
    If Text1.Text = "" Then Record.Enabled = False
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -