悬赏!求课程设计任务书!!“设计CA6140车床输出轴零件机械加工工艺规程及工艺装备!!
发布网友
发布时间:2022-05-04 18:43
我来回答
共2个回答
热心网友
时间:2023-10-05 15:34
'窗体不用添加任何控件的计算机,只需复制代码即可。
Option Explicit
Dim 按钮(3, 3) As String
Dim 数 As String, 数1 As String, 显示 As String, 计算 As String
Dim 开始 As Boolean, mXs As Boolean, 复位 As Boolean
Dim pX As Integer, pY As Integer, mW As Long, mH As Long, bW As Long, bH As Long
Const Pi As Double = 3.1415926
'过程和函数
Private Sub ItemSkin(ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, _
ByVal Caption As String, Optional ByVal State As Integer = 0)
Dim i As Long
Select Case State
Case 0
For i = Y1 To Y2 Step 15
Line (X1, i)-(X2, i), RGB(160 + 95 * (Y2 - i) / (Y2 - Y1), 160 + 95 * (Y2 - i) / (Y2 - Y1), 160 + 95 * (Y2 - i) / (Y2 - Y1)), B
Next
PSet (X1 + 2 * pX, Y1 + 2 * pY), &H80000010
PSet (X2 - 2 * pX, Y1 + 2 * pY), &H80000010
PSet (X1 + 2 * pX, Y2 - 2 * pY), &H80000010
PSet (X2 - 2 * pX, Y2 - 2 * pY), &H80000010
Line (X1 + pX, Y1 + pX)-(X2 - pX, Y2 - pY), &H80000010, B
Case 1
For i = Y1 To Y2 Step 15
Line (X1, i)-(X2, i), RGB(160 + 95 * (Y2 - i) / (Y2 - Y1), 160 + 95 * (Y2 - i) / (Y2 - Y1), 160 + 95 * (Y2 - i) / (Y2 - Y1)), B
Next
Line (X1 + pX, Y1 + pX)-(X2 - pX, Y2 - pY), &H80C0FF, B
Line (X1 + 2 * pX, Y1 + 2 * pX)-(X2 - 2 * pX, Y2 - 2 * pY), &H80C0FF, B
Case 2
For i = Y1 To Y2 Step 15
Line (X1, i)-(X2, i), RGB(255 - 95 * (Y2 - i) / (Y2 - Y1), 255 - 95 * (Y2 - i) / (Y2 - Y1), 255 - 95 * (Y2 - i) / (Y2 - Y1)), B
Next
PSet (X1 + 2 * pX, Y1 + 2 * pY), &H80000015
PSet (X2 - 2 * pX, Y1 + 2 * pY), &H80000015
PSet (X1 + 2 * pX, Y2 - 2 * pY), &H80000015
PSet (X2 - 2 * pX, Y2 - 2 * pY), &H80000015
Line (X1 + pX, Y1 + pX)-(X2 - pX, Y2 - pY), &H80000015, B
End Select
PSet (X1 + pX, Y1 + pY), &HA06040
PSet (X2 - pX, Y1 + pY), &HA06040
PSet (X1 + pX, Y2 - pY), &HA06040
PSet (X2 - pX, Y2 - pY), &HA06040
Line (X1, Y1)-(X2, Y2), &HA06040, B
PSet (X1, Y1), Me.BackColor
PSet (X1, Y2), Me.BackColor
PSet (X2, Y1), Me.BackColor
PSet (X2, Y2), Me.BackColor
Me.CurrentX = (X2 - X1 - Me.TextWidth(Caption)) / 2 + X1
Me.CurrentY = (Y2 - Y1 - Me.TextHeight(Caption)) / 2 + Y1
Print Caption
End Sub
Private Sub FormRecord(ByVal i显示 As String, Optional ByVal i计算 As String = "")
Dim iX As Integer, iY As Integer
Cls
Line (1200, 240)-(mW - 240, 600), &H80000005, BF
Line (1200, 240)-(mW - 240, 600), &HC0A0A0, B
ItemSkin 240, 240, 1080, 600, "AC"
For iX = 0 To 3
For iY = 0 To 3
ItemSkin bW * iX + 240, bH * iY + 840, bW * (iX + 1) - 120, bH * (iY + 1) + 600, 按钮(iX, iY)
Next
Next
Me.CurrentX = mW - Me.TextWidth(i显示) - 360
Me.CurrentY = (360 - Me.TextHeight(i显示)) / 2 + 240
Print i显示
Me.CurrentX = 1320
Me.CurrentY = (360 - Me.TextHeight(i计算)) / 2 + 240
Print i计算
End Sub
Private Sub mMouseMove(Button As Integer, X As Single, Y As Single)
Dim iX As Integer, iY As Integer
If X > 240 And X < 1080 And Y > 240 And Y < 600 Then
ItemSkin 240, 240, 1080, 600, "AC", IIf(Button = 1, 2, 1)
ElseIf X < 240 Or X > mW - 240 Or Y < 840 Or Y > mH - 240 Then
FormRecord Format(显示, "0.#######"), 计算
Else
For iX = 0 To 3
For iY = 0 To 3
If X > bW * iX + 240 And Y > bH * iY + 840 And X < bW * (iX + 1) - 120 And Y < bH * (iY + 1) + 600 Then
ItemSkin bW * iX + 240, bH * iY + 840, bW * (iX + 1) - 120, bH * (iY + 1) + 600, 按钮(iX, iY), IIf(Button = 1, 2, 1)
Else
ItemSkin bW * iX + 240, bH * iY + 840, bW * (iX + 1) - 120, bH * (iY + 1) + 600, 按钮(iX, iY)
End If
Next
Next
End If
End Sub
Private Function mCount(ByVal i数 As String, ByVal i计算 As String, Optional ByVal i等 As Boolean = False) As String
On Error GoTo ErrStr
If 计算 <> i计算 Then
计算 = i计算
数1 = 数
mCount = 数
ElseIf (i等 Or 开始 = False) And 计算 <> "" Then
Select Case 计算
Case "+"
数1 = Val(数1) + Val(i数)
Case "-"
数1 = Val(数1) - Val(i数)
Case "*"
数1 = Val(数1) * Val(i数)
Case "/"
数1 = Val(数1) / Val(i数)
End Select
mCount = 数1
ElseIf i等 Then
mCount = 数
Else
mCount = 数1
End If
复位 = i等
开始 = True
Exit Function
ErrStr:
显示 = 0
数 = 0
数1 = 0
开始 = False
mXs = False
计算 = ""
mCount = "Error"
End Function
'事件
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Or KeyAscii = 27 Then
显示 = 0
数 = 0
数1 = 0
计算 = ""
mXs = False
ElseIf Chr(KeyAscii) >= 0 And Chr(KeyAscii) < 10 Then
If 开始 Then 数 = 0
If 复位 Then
数1 = 0
计算 = ""
End If
If Len(CStr(Val(显示))) < 8 Then 数 = 数 & IIf(mXs, ".", "") & Chr(KeyAscii)
显示 = 数
开始 = False
mXs = False
复位 = False
ElseIf Chr(KeyAscii) = "." Then
If Int(显示) = 显示 Then mXs = True
ElseIf Chr(KeyAscii) = "+" Or Chr(KeyAscii) = "-" Or Chr(KeyAscii) = "*" Or Chr(KeyAscii) = "/" Then
显示 = mCount(数, Chr(KeyAscii))
ElseIf Chr(KeyAscii) = "=" Then
显示 = mCount(数, 计算, True)
End If
FormRecord Format(显示, "0.#######"), 计算
End Sub
Private Sub Form_Load()
Dim iX As Integer, iY As Integer, n As Integer
pX = Screen.TwipsPerPixelX
pY = Screen.TwipsPerPixelY
Me.AutoRedraw = True
Me.KeyPreview = True
Me.FontSize = 12
Me.Caption = "计算器"
For iY = 0 To 2
For iX = 0 To 2
n = n + 1
按钮(iX, iY) = n
Next
Next
按钮(3, 0) = "*"
按钮(3, 1) = "/"
按钮(3, 2) = "-"
按钮(3, 3) = "+"
按钮(0, 3) = "0"
按钮(1, 3) = "."
按钮(2, 3) = "="
显示 = 0
数 = 0
数1 = 0
开始 = True
FormRecord Format(显示, "0.#######"), 计算
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then mMouseMove Button, X, Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
mMouseMove Button, X, Y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > 240 And X < 1080 And Y > 240 And Y < 600 Then
显示 = 0
数 = 0
数1 = 0
计算 = ""
mXs = False
ElseIf X < 240 Or X > mW - 240 Or Y < 840 Or Y > mH - 240 Then
ElseIf (X - 240) \ bW = 3 Then
显示 = mCount(数, 按钮((X - 240) \ bW, (Y - 840) \ bH))
ElseIf (X - 240) \ bW = 2 And (Y - 840) \ bH = 3 Then
显示 = mCount(数, 计算, True)
ElseIf (X - 240) \ bW = 1 And (Y - 840) \ bH = 3 Then
If Int(显示) = 显示 Then mXs = True
Else
If 开始 Then 数 = 0
If 复位 Then
数1 = 0
计算 = ""
End If
If Len(CStr(Val(显示))) < 8 Then 数 = 数 & IIf(mXs, ".", "") & (按钮((X - 240) \ bW, (Y - 840) \ bH))
显示 = 数
开始 = False
mXs = False
复位 = False
End If
FormRecord Format(显示, "0.#######"), 计算
End Sub
Private Sub Form_Resize()
mW = IIf(Me.ScaleWidth > 3000, Me.ScaleWidth, 3000)
mH = IIf(Me.ScaleHeight > 3000, Me.ScaleHeight, 3000)
bW = (mW - 120) / 4
bH = (mH - 840) / 4
FormRecord Format(显示, "0.#######"), 计算
End Sub
热心网友
时间:2023-10-05 15:35
建议: 四、数据导入和同步