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

📄 sim.frm

📁 This code outputs various NMEA strings to a com port. The code was originally used to test naviati
💻 FRM
📖 第 1 页 / 共 4 页
字号:
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   600
         TabIndex        =   35
         Top             =   240
         Width           =   1380
      End
      Begin VB.Label lbl_ns 
         Alignment       =   2  'Center
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   495
         Left            =   6360
         TabIndex        =   28
         Top             =   600
         Width           =   495
      End
      Begin VB.Label lbl_ew 
         Alignment       =   2  'Center
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   495
         Left            =   6360
         TabIndex        =   27
         Top             =   1320
         Width           =   495
      End
      Begin VB.Label lbl_end_lon_deg 
         Alignment       =   1  'Right Justify
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   495
         Left            =   4680
         TabIndex        =   26
         Top             =   1320
         Width           =   615
      End
      Begin VB.Label lbl_end_lat_min 
         Alignment       =   2  'Center
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   495
         Left            =   5400
         TabIndex        =   25
         Top             =   600
         Width           =   855
      End
      Begin VB.Label lbl_end_lon_min 
         Alignment       =   2  'Center
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   495
         Left            =   5400
         TabIndex        =   24
         Top             =   1320
         Width           =   855
      End
      Begin VB.Label lbl_end_lat_deg 
         Alignment       =   1  'Right Justify
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   495
         Left            =   4680
         TabIndex        =   23
         Top             =   600
         Width           =   615
      End
   End
   Begin MSCommLib.MSComm nmea_com 
      Left            =   120
      Top             =   0
      _ExtentX        =   688
      _ExtentY        =   688
      _Version        =   393216
      DTREnable       =   -1  'True
      BaudRate        =   4800
   End
   Begin VB.Label Label8 
      AutoSize        =   -1  'True
      BackColor       =   &H00C0C0C0&
      Caption         =   "NMEA Message"
      Height          =   192
      Left            =   3000
      TabIndex        =   0
      Top             =   3600
      Visible         =   0   'False
      Width           =   1188
   End
End
Attribute VB_Name = "sim_frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

 Dim distance
 Dim pi, hdg
 Dim start_lat, start_lon, end_lat, end_lon
 Dim port_open_flag
 Dim i%
 Dim Counter
 Dim lat_count
 Dim last_update
 
 
 
 
Sub check_dateline()
    If Val(lbl_end_lon_deg.Caption) >= 180 Then
        If lbl_ew.Caption = "W" Then
        lbl_ew.Caption = "E"
        Else
        lbl_ew.Caption = "W"
        End If
    lbl_end_lon_deg.Caption = "179"
    End If
    
   
End Sub





Private Sub cmd_com_Click()
    fra_com.Visible = True
End Sub

Private Sub cmd_exit_Click()
    If nmea_com.PortOpen = True Then
    nmea_com.PortOpen = False
    End If
    
    End
End Sub

Private Sub cmd_pause_Click()
    
    
    If Timer1.Enabled = True Then
    Timer1.Enabled = False
    cmd_pause.Caption = "Continue"
    Else
    Timer1.Enabled = True
    cmd_pause.Caption = "Pause"
    End If
    
    
End Sub

Private Sub cmd_reset_Click()
    'Reset to start position
    lbl_end_lat_deg.Caption = txt_st_lat_deg.Text
    lbl_end_lat_min.Caption = txt_st_lat_min.Text
    lbl_end_lon_deg.Caption = txt_st_lon_deg.Text
    lbl_end_lon_min.Caption = txt_st_lon_min.Text
    lbl_ns.Caption = txt_ns.Text
    lbl_ew.Caption = txt_ew.Text
    cmd_reset.Enabled = False
    lat_count = 0
    Counter = 0
    Call cmd_rudder_Click
    txt_hdg.Text = "000"
End Sub

Private Sub cmd_rudder_Click()
    port_rudder.FloodPercent = 0
    stbd_rudder.FloodPercent = 0
    port_rudder.FloodPercent = port_rudder.FloodPercent + 3
    stbd_rudder.FloodPercent = stbd_rudder.FloodPercent + 3
    
End Sub

Private Sub cmd_start_Click()
    
    If txt_ns.Text = "" Or txt_ew.Text = "" Then
    MsgBox "Illegal start position."
    Exit Sub
    End If
    
    If com_nmea.Text = "" Then
    MsgBox "Select message type,"
    Exit Sub
    End If
    On Error GoTo port_err
    If nmea_com.PortOpen = False Then nmea_com.PortOpen = True
    port_open_flag = True
    Timer1.Enabled = True
    cmd_pause.Enabled = True
    
    Exit Sub
port_err:
If Err > 0 Then
MsgBox "This port already in use."
port_open_flag = False
If nmea_com.PortOpen Then
    nmea_com.PortOpen = False
    End If
Exit Sub
End If

End Sub

Private Sub cmd_stop_Click()
    If Timer1.Enabled = True Then
    Timer1.Enabled = False
    Else
    Timer1.Enabled = False
    End If
    cmd_reset.Enabled = True
    If nmea_com.PortOpen = True Then
    nmea_com.PortOpen = False
    End If
    port_open_flag = False
    cmd_pause.Enabled = False
    
End Sub

Private Sub Form_Load()
    
    
    pi = 22 / 7

     
    sim_frm.WindowState = 0
    
    com_nmea.AddItem "All"
    com_nmea.AddItem "GLL"
    com_nmea.AddItem "GGA"
    com_nmea.AddItem "RMC"
    
    com_nmea.Text = "All"
    
    
    port_rudder.FloodPercent = port_rudder.FloodPercent + 3
    stbd_rudder.FloodPercent = stbd_rudder.FloodPercent + 3
    

End Sub

Private Sub SpinButton1_SpinDown()
    If txt_speed.Text <> "0" Then
    txt_speed.Text = Val(txt_speed.Text) - 1
    End If
End Sub

Private Sub SpinButton1_SpinUp()
    
    txt_speed.Text = Val(txt_speed.Text) + 1
    
End Sub


Private Sub SpinButton2_SpinDown()
    
    For i% = 0 To 10
    If port_rudder.FloodPercent > 99.9 Then Exit For
    port_rudder.FloodColor = &HFF&
    If stbd_rudder.FloodPercent >= 1 Then
    stbd_rudder.FloodPercent = stbd_rudder.FloodPercent - 1
    Else
    port_rudder.FloodPercent = port_rudder.FloodPercent + 1
    End If
    Next i%
    
    If port_rudder.FloodPercent = 0 Then port_rudder.FloodPercent = 3
    
    If (txt_hdg.Text) = "000" Then txt_hdg.Text = "360"
    
    If txt_hdg.Text >= "001" Then
    txt_hdg.Text = Format(Val(txt_hdg.Text - 1), "000")
    Else
    txt_hdg.Text = 360 - Format(Val(txt_hdg.Text - 1), "000")
    End If
    
    txt_hdg.Text = Format(Val(txt_hdg.Text), "000")
    
End Sub


Private Sub SpinButton3_SpinUp()
    
    stbd_rudder.FloodColor = &H8000&
    For i% = 0 To 10 'port_rudder.Percent
    If stbd_rudder.FloodPercent > 99.9 Then Exit For
    If port_rudder.FloodPercent >= 1 Then
    port_rudder.FloodPercent = port_rudder.FloodPercent - 1
    Else
    stbd_rudder.FloodPercent = stbd_rudder.FloodPercent + 1

⌨️ 快捷键说明

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