📄 sinwave.frm
字号:
VERSION 5.00
Begin VB.Form Sin_wave
Caption = "Sin波发生"
ClientHeight = 5970
ClientLeft = 2535
ClientTop = 2175
ClientWidth = 8295
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 5970
ScaleWidth = 8295
Begin VB.CommandButton Command6
Caption = "退出"
Height = 375
Left = 3480
TabIndex = 22
Top = 5280
Width = 1335
End
Begin VB.Frame Frame3
Caption = "文件变换"
Height = 2415
Left = 5760
TabIndex = 18
Top = 840
Width = 2295
Begin VB.CommandButton Command5
Caption = "OBJ to BIN 转换"
Height = 495
Left = 240
TabIndex = 20
Top = 1200
Width = 1575
End
Begin VB.TextBox Text5
Height = 270
Left = 120
TabIndex = 19
Text = "d:\"
Top = 720
Width = 1935
End
Begin VB.Label Label6
BackColor = &H0080FFFF&
Caption = "obj_to_bin.exe 路径"
Height = 255
Left = 120
TabIndex = 21
Top = 480
Width = 1935
End
End
Begin VB.Frame Frame2
Caption = "文件保存"
Height = 2415
Left = 2400
TabIndex = 9
Top = 840
Width = 3135
Begin VB.CommandButton datapro
Caption = "保存"
Enabled = 0 'False
Height = 375
Left = 2280
TabIndex = 14
Top = 1320
Width = 615
End
Begin VB.CommandButton Command4
Caption = "保存"
Enabled = 0 'False
Height = 375
Left = 2280
TabIndex = 13
Top = 840
Width = 615
End
Begin VB.TextBox Text2
Height = 270
Left = 840
TabIndex = 12
Text = "d:\"
Top = 360
Width = 1335
End
Begin VB.TextBox Text3
Height = 270
Left = 840
TabIndex = 11
Text = "test.txt"
Top = 1320
Width = 1335
End
Begin VB.TextBox Text4
Height = 270
Left = 840
TabIndex = 10
Text = "test.obj"
Top = 840
Width = 1335
End
Begin VB.Label Label3
BackColor = &H0080FFFF&
Caption = "路径"
Height = 255
Left = 120
TabIndex = 17
Top = 360
Width = 735
End
Begin VB.Label Label4
BackColor = &H0080FFFF&
Caption = "TXT文件"
Height = 255
Left = 120
TabIndex = 16
Top = 1320
Width = 735
End
Begin VB.Label Label5
BackColor = &H0080FFFF&
Caption = "OBJ文件"
Height = 255
Left = 120
TabIndex = 15
Top = 840
Width = 735
End
End
Begin VB.TextBox Text6
Height = 270
Left = 1200
TabIndex = 7
Text = "1"
Top = 1680
Width = 615
End
Begin VB.Frame Frame1
Caption = "Sin 波形发生"
Height = 2415
Left = 240
TabIndex = 2
Top = 840
Width = 1935
Begin VB.CommandButton Command3
Caption = "Cls"
Height = 375
Left = 240
TabIndex = 6
Top = 1800
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "数据生成"
Height = 375
Left = 240
TabIndex = 4
Top = 1320
Width = 1335
End
Begin VB.TextBox Text1
Height = 270
Left = 960
TabIndex = 3
Text = "16"
Top = 360
Width = 615
End
Begin VB.Label Label7
BackColor = &H0080FFFF&
Caption = "X轴扩展"
Height = 255
Left = 240
TabIndex = 8
Top = 840
Width = 735
End
Begin VB.Label Label1
BackColor = &H0080FFFF&
Caption = "数据长度"
Height = 255
Left = 240
TabIndex = 5
Top = 360
Width = 735
End
End
Begin VB.CommandButton Command1
Caption = "Exit"
BeginProperty Font
Name = "MS PMincho"
Size = 11.25
Charset = 128
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5760
TabIndex = 0
Top = 7560
Width = 1095
End
Begin VB.Label Label2
Alignment = 2 'Center
BackColor = &H00C0FFFF&
Caption = "8bit Sin波发生"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2760
TabIndex = 1
Top = 240
Width = 3495
End
End
Attribute VB_Name = "Sin_wave"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub form_init()
Width = 8415
Height = 6375
Left = (Screen.Width - Width) / 2
Top = (Screen.Height - Height) / 2
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Dim n As Integer
Const offset_x = 100
Const offset_y = 420
Const Vm = 127
ScaleMode = 3
For n = 0 To Max_data
amp(n) = Vm * (1 - Sin(2 * 3.14 * n / Max_data))
Next
CurrentX = offset_x
CurrentY = offset_y - Vm + 20
For n = 0 To Max_data
Line -(n / Text6 + offset_x, -amp(n) * 0.5 + offset_y - 40)
Next
CurrentX = 0
CurrentY = 20
DoEvents
Command4.Enabled = True
datapro.Enabled = True
End Sub
Private Sub Command3_Click()
Cls
End Sub
Private Sub Command4_Click()
Dim data As String
Dim i As Integer
Dim file_dir As String
Dim file_name As String
file_dir = Text2.Text
file_name = file_dir + Text4.Text
Open file_name For Binary As #1 Len = 2
data = Hex(0)
data = Format(data, "0000")
Put #1, , data
data = "0000" + Hex(Max_data)
data = Right(data, 4)
Put #1, , data
For i = 1 To Max_data
data = "0" + Hex(amp(i - 1))
data = Right(data, 2)
Put #1, , data
Next i
Close #1
Beep
MsgBox "OK!"
End Sub
Private Sub Command5_Click()
Dim obj_exe As String
Dim exe_file As String
obj_exe = Text5.Text
exe_file = obj_exe + "obj_to_bin.exe"
RetVal = Shell(exe_file, 1)
End Sub
Private Sub Command6_Click()
End
End Sub
Private Sub datapro_Click()
Dim i As Integer
Dim out_data, t, d As String
Dim file_dir As String
Dim file_name As String
file_dir = Text2.Text
file_name = file_dir + Text3.Text
HT$ = Chr(9)
Open file_name For Output As #1
Print #1, "TIME" + HT$ + "DATA"
For i = 0 To Max_data - 1
t = Str(i + 1)
d = amp(i)
Print #1, t + HT$ + d
Next
Close #1
Beep
MsgBox "OK!"
End Sub
Private Sub Form_Load()
form_init
Max_data = Text1.Text
End Sub
Private Sub Text1_Change()
Max_data = Text1.Text
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -