- UID
- 418
- 精华
- 积分
- 3994
- 威望
- 点
- 宅币
- 个
- 贡献
- 次
- 宅之契约
- 份
- 最后登录
- 1970-1-1
- 在线时间
- 小时
|
发表于 2014-12-31 19:17:36
|
显示全部楼层
{:soso_e179:} 哈哈哈哈!好!跟风发一个:
- VERSION 5.00
- Begin VB.Form Form1
- BorderStyle = 1 'Fixed Single
- Caption = "SCAL"
- ClientHeight = 4305
- ClientLeft = 45
- ClientTop = 375
- ClientWidth = 4545
- Icon = "Form1.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 4305
- ScaleWidth = 4545
- StartUpPosition = 2 '屏幕中心
- Begin VB.CommandButton Command3
- Caption = "&X"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 3600
- TabIndex = 28
- ToolTipText = "清空"
- Top = 120
- Width = 375
- End
- Begin VB.Frame Frame2
- Caption = "单位转换"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1695
- Left = 120
- TabIndex = 17
- Top = 2520
- Width = 4335
- Begin VB.CommandButton Command4
- Caption = "&D"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 3840
- TabIndex = 29
- ToolTipText = "清空"
- Top = 240
- Width = 375
- End
- Begin VB.TextBox Text6
- BackColor = &H8000000F&
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF0000&
- Height = 375
- Left = 1080
- Locked = -1 'True
- TabIndex = 25
- Text = "0"
- Top = 1200
- Width = 3135
- End
- Begin VB.ComboBox Combo2
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000080&
- Height = 330
- Left = 2760
- Style = 2 'Dropdown List
- TabIndex = 23
- Top = 720
- Width = 1455
- End
- Begin VB.ComboBox Combo1
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00008000&
- Height = 330
- Left = 1080
- Style = 2 'Dropdown List
- TabIndex = 21
- Top = 720
- Width = 1455
- End
- Begin VB.TextBox Text5
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 1080
- TabIndex = 19
- Text = "0"
- Top = 240
- Width = 2775
- End
- Begin VB.Label Label4
- AutoSize = -1 'True
- Caption = "输出(&O):"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 1
- Left = 120
- TabIndex = 24
- Top = 1320
- Width = 810
- End
- Begin VB.Label Label3
- AutoSize = -1 'True
- Caption = "到"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 1
- Left = 2520
- TabIndex = 22
- Top = 840
- Width = 195
- End
- Begin VB.Label Label2
- AutoSize = -1 'True
- Caption = "单位(&S):"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 1
- Left = 120
- TabIndex = 20
- Top = 840
- Width = 810
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "输入(&I):"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 1
- Left = 120
- TabIndex = 18
- Top = 360
- Width = 810
- End
- End
- Begin VB.CheckBox Check2
- Height = 375
- Left = 4080
- Picture = "Form1.frx":0CCA
- Style = 1 'Graphical
- TabIndex = 13
- ToolTipText = "工具"
- Top = 1080
- Width = 375
- End
- Begin VB.Frame Frame1
- Caption = "设置"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 735
- Left = 120
- TabIndex = 12
- Top = 1680
- Width = 4335
- Begin VB.CommandButton Command2
- Caption = "&R"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 3840
- TabIndex = 16
- ToolTipText = "复位"
- Top = 240
- Width = 375
- End
- Begin VB.TextBox Text4
- BackColor = &H0000C0C0&
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FFFFFF&
- Height = 375
- Left = 2160
- TabIndex = 15
- Text = "10"
- Top = 240
- Width = 1335
- End
- Begin VB.Label Label5
- AutoSize = -1 'True
- Caption = "位"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 1
- Left = 3600
- TabIndex = 27
- Top = 360
- Width = 195
- End
- Begin VB.Label Label5
- AutoSize = -1 'True
- Caption = "小数精度(&A):小数点后"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 0
- Left = 120
- TabIndex = 14
- Top = 360
- Width = 1980
- End
- End
- Begin VB.CheckBox Check1
- Caption = "&T"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 4080
- Style = 1 'Graphical
- TabIndex = 11
- ToolTipText = "窗口置顶"
- Top = 600
- Width = 375
- End
- Begin VB.CommandButton Command1
- Caption = "&?"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 4080
- TabIndex = 10
- ToolTipText = "关于"
- Top = 120
- Width = 375
- End
- Begin VB.TextBox Text3
- BackColor = &H8000000F&
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF0000&
- Height = 375
- Left = 960
- Locked = -1 'True
- TabIndex = 9
- Text = "0"
- Top = 1080
- Width = 2655
- End
- Begin VB.VScrollBar VScroll1
- Height = 375
- Index = 1
- Left = 3720
- Max = 36
- Min = 2
- TabIndex = 7
- Top = 600
- Value = 10
- Width = 255
- End
- Begin VB.TextBox Text2
- BackColor = &H00000080&
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FFFFFF&
- Height = 375
- Index = 1
- Left = 2640
- TabIndex = 6
- Text = "10"
- Top = 600
- Width = 1095
- End
- Begin VB.VScrollBar VScroll1
- Height = 375
- Index = 0
- Left = 2040
- Max = 36
- Min = 2
- TabIndex = 4
- Top = 600
- Value = 10
- Width = 255
- End
- Begin VB.TextBox Text2
- BackColor = &H00008000&
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FFFFFF&
- Height = 375
- Index = 0
- Left = 960
- TabIndex = 3
- Text = "10"
- Top = 600
- Width = 1095
- End
- Begin VB.TextBox Text1
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000000&
- Height = 375
- Left = 960
- TabIndex = 1
- Text = "0"
- Top = 120
- Width = 2655
- End
- Begin VB.Label Label6
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- BeginProperty Font
- Name = "宋体"
- Size = 7.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF0000&
- Height = 375
- Left = 3600
- TabIndex = 26
- Top = 1080
- Width = 375
- End
- Begin VB.Label Label4
- AutoSize = -1 'True
- Caption = "输出(&O):"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 0
- Left = 120
- TabIndex = 8
- Top = 1200
- Width = 810
- End
- Begin VB.Label Label3
- AutoSize = -1 'True
- Caption = "到"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 0
- Left = 2400
- TabIndex = 5
- Top = 720
- Width = 195
- End
- Begin VB.Label Label2
- AutoSize = -1 'True
- Caption = "进制(&S):"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 0
- Left = 120
- TabIndex = 2
- Top = 720
- Width = 810
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "输入(&I):"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 180
- Index = 0
- Left = 120
- TabIndex = 0
- Top = 240
- Width = 810
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
- Private Enum sConvA
- A_Bit = 0
- A_Byte = 1
- A_KB = 2
- A_MB = 3
- A_GB = 4
- A_TB = 5
- End Enum
- Private Function CboNameToNum(name As String) As Integer
- Select Case name
- Case "位(bit)"
- CboNameToNum = 0
- Case "字节(Byte)"
- CboNameToNum = 1
- Case "千字节(KB)"
- CboNameToNum = 2
- Case "兆字节(MB)"
- CboNameToNum = 3
- Case "吉字节(GB)"
- CboNameToNum = 4
- Case "太字节(TB)"
- CboNameToNum = 5
- End Select
- End Function
- Private Function AnyToKB(ress As sConvA, inNum As Double) As Double
- On Error GoTo EH_ATK:
- Select Case ress
- Case 0
- AnyToKB = 1 / (8 * 1024) * inNum
- Case 1
- AnyToKB = 1 / 1024 * inNum
- Case 2
- AnyToKB = inNum
- Case 3
- AnyToKB = 1024 * inNum
- Case 4
- AnyToKB = 1024 ^ 2 * inNum
- Case 5
- AnyToKB = 1024 ^ 3 * inNum
- End Select
- Exit Function
- EH_ATK:
- AnyToKB = 0
- End Function
- Private Function KBToAny(ress As sConvA, inNum As Double) As Double
- On Error GoTo EH_KTA:
- Select Case ress
- Case 0
- KBToAny = 1024 * 8 * inNum
- Case 1
- KBToAny = 1024 * inNum
- Case 2
- KBToAny = inNum
- Case 3
- KBToAny = 1 / 1024 * inNum
- Case 4
- KBToAny = 1 / (1024 ^ 2) * inNum
- Case 5
- KBToAny = 1 / (1024 ^ 3) * inNum
- End Select
- Exit Function
- EH_KTA:
- KBToAny = "错误"
- End Function
- Private Function DecToAny(sScal As Integer, aCC As Long, inNum As String) As String
- On Error GoTo EH_DTA:
- Dim numPart() As String
- Dim tMod As Long, tN As Double
- Dim ts As String, ts2 As String
- Dim i As Long
- Dim intPart As String, floatPart As String
- If Len(inNum) = 0 Then Exit Function
- numPart = Split(UCase(inNum), ".")
- intPart = vbNullString: tN = Val(numPart(0)): ts = vbNullString
- Do
- tMod = tN Mod sScal
- tN = Int(tN / sScal)
-
- ts2 = CStr(tMod)
- If Len(ts2) >= 2 Then ts2 = Chr(Int(ts2) + 55)
- ts = ts & ts2
- Loop While tN >= 1
- intPart = StrReverse(ts)
-
- If InStr(inNum, ".") Then
- floatPart = vbNullString: tN = CDbl("0." & numPart(1)): ts = vbNullString: ts2 = vbNullString
- For i = 1 To aCC
- If tN = Int(tN) Then Exit For
- tN = tN * sScal
- ts2 = CStr(Int(tN))
- If Len(ts2) >= 2 Then ts2 = Chr(Int(ts2) + 55)
- ts = ts & ts2
-
- If InStr(CStr(tN), ".") Then tN = CDbl("." & Split(CStr(tN), ".")(1))
- Next
- floatPart = "." & ts
- End If
- DecToAny = intPart & floatPart
- Exit Function
- EH_DTA:
- DecToAny = "错误"
- End Function
- Private Function AnyToDec(sScal As Integer, inNum As String) As String
- On Error GoTo EH_ATD:
- Dim numPart() As String
- Dim i As Long, j As Long
- Dim ts As String
- Dim intPart As Long, floatPart As Double
- If Len(inNum) = 0 Then Exit Function
- numPart = Split(UCase(inNum), ".")
- intPart = 0: j = 0
- For i = Len(numPart(0)) - 1 To 0 Step -1
- ts = Mid(numPart(0), i + 1, 1)
- If Asc(ts) >= 65 And Asc(ts) <= 90 Then ts = CStr(Asc(ts) - 55)
- intPart = intPart + sScal ^ j * Int(ts)
- j = j + 1
- Next
- j = 0: floatPart = 0
- If InStr(inNum, ".") Then
- For i = 1 To Len(numPart(1))
- ts = Mid(numPart(1), i, 1)
- If Asc(ts) >= 65 And Asc(ts) <= 90 Then ts = CStr(Asc(ts) - 55)
- floatPart = floatPart + sScal ^ -i * Int(ts)
- Next
- End If
- AnyToDec = CStr(intPart + floatPart)
- Exit Function
- EH_ATD:
- AnyToDec = "错误"
- End Function
- Private Function IsLawful(a As String, scal As Integer) As Boolean
- If Asc(a) < 48 Or Asc(a) > 57 Then
- If (Asc(UCase(a)) - 54) > scal Then IsLawful = False Else IsLawful = True
- Else
- If (Asc(a) - 47) > scal Then IsLawful = False Else IsLawful = True
- End If
- End Function
- Private Function InFloOnly(keyNum As Integer) As Boolean
- If (keyNum >= 48 And keyNum <= 57) Or keyNum = 8 Or keyNum = 16 Or keyNum = 46 Then
- InFloOnly = True
- Else
- InFloOnly = False
- End If
- End Function
- Private Function InIntOnly(keyNum As Integer) As Boolean
- If (keyNum >= 48 And keyNum <= 57) Or keyNum = 8 Or keyNum = 16 Then
- InIntOnly = True
- Else
- InIntOnly = False
- End If
- End Function
- Private Function InNumOnly(keyNum As Integer) As Boolean
- If (keyNum >= 48 And keyNum <= 57) Or (keyNum >= 65 And keyNum <= 90) Or (keyNum >= 97 And keyNum <= 122) Or keyNum = 45 Or keyNum = 8 Or keyNum = 16 Or keyNum = 46 Then
- InNumOnly = True
- Else
- InNumOnly = False
- End If
- End Function
- Private Sub Check1_Click()
- If Check1.Value = 1 Then
- SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
- Else
- SetWindowPos Me.hwnd, -2, 0, 0, 0, 0, 3
- End If
- End Sub
- Private Sub Check2_Click()
- If Check2.Value = 1 Then
- Me.Height = 4725
- Else
- Me.Height = 1965
- End If
- End Sub
- Private Sub Combo1_Click()
- Call Text5_Change
- End Sub
- Private Sub Combo2_Click()
- Call Text5_Change
- End Sub
- Private Sub Command1_Click()
- Dim info As String
- info = "SCAL v1.0" & vbCrLf
- info = info & "Copyright (C) 2013 Ctechnology Corp." & vbCrLf
- info = info & "PID:201309192151A" & vbCrLf
- info = info & "Created By Cyycoish" & vbCrLf
- info = info & "Email:cyycoish@hotmail.com" & vbCrLf
- MsgBox info, , "About SCAL"
- End Sub
- Private Sub Command2_Click()
- Text4.Text = "10"
- End Sub
- Private Sub Command3_Click()
- Text1.Text = "0"
- Text1.SelStart = 0
- Text1.SelLength = Len(Text1.Text)
- Text1.SetFocus
- End Sub
- Private Sub Command4_Click()
- Text5.Text = "0"
- Text5.SelStart = 0
- Text5.SelLength = Len(Text5.Text)
- Text5.SetFocus
- End Sub
- Private Sub Form_Load()
- Text1.SelStart = 0
- Text1.SelLength = Len(Text1.Text)
- Me.Height = 1965
- Label6.Caption = vbCrLf & Text2(1).Text
-
- Combo1.AddItem "位(bit)"
- Combo1.AddItem "字节(Byte)"
- Combo1.AddItem "千字节(KB)"
- Combo1.AddItem "兆字节(MB)"
- Combo1.AddItem "吉字节(GB)"
- Combo1.AddItem "太字节(TB)"
- Combo1.Text = Combo1.List(0)
-
- Combo2.AddItem "位(bit)"
- Combo2.AddItem "字节(Byte)"
- Combo2.AddItem "千字节(KB)"
- Combo2.AddItem "兆字节(MB)"
- Combo2.AddItem "吉字节(GB)"
- Combo2.AddItem "太字节(TB)"
- Combo2.Text = Combo2.List(0)
- End Sub
- Private Sub Text1_Change()
- Dim i As Long
- Dim ts As String
- Dim j As Integer
- j = 0
- Text1.ForeColor = &H0&
- For i = 1 To Len(Text1.Text)
- ts = Mid(Text1.Text, i, 1)
- If ts = "." Then j = j + 1
- If j > 1 Then
- Text1.SelStart = i - 1
- Text1.SelLength = 1
- Text1.ForeColor = &HFF&
- Exit Sub
- End If
- If i <> 1 And ts = "-" Then
- Text1.SelStart = i - 1
- Text1.SelLength = 1
- Text1.ForeColor = &HFF&
- Exit Sub
- End If
- If IsLawful(ts, Int(Text2(0).Text)) = False Then
- Text1.SelStart = i - 1
- Text1.SelLength = 1
- Text1.ForeColor = &HFF&
- Exit Sub
- End If
- Next
- Text3.Text = DecToAny(Int(Text2(1).Text), Int(Text4.Text), AnyToDec(Int(Text2(0).Text), Text1.Text))
- End Sub
- Private Sub Text1_KeyPress(KeyAscii As Integer)
- If InNumOnly(KeyAscii) = False Then KeyAscii = 0
- End Sub
- Private Sub Text2_Change(Index As Integer)
- If Val(Text2(Index).Text) > 36 Then Text2(Index).Text = "36"
- If Int(Text2(Index).Text) > 1 Then Call Text1_Change
- Label6.Caption = vbCrLf & Text2(1).Text
- End Sub
- Private Sub Text2_KeyPress(Index As Integer, KeyAscii As Integer)
- If InIntOnly(KeyAscii) = False Then KeyAscii = 0
- End Sub
- Private Sub Text2_LostFocus(Index As Integer)
- If Val(Text2(Index).Text) < 2 Then Text2(Index).Text = "2"
- If Val(Text2(Index).Text) > 36 Then Text2(Index).Text = "36"
- Call Text1_Change
- End Sub
- Private Sub Text4_Change()
- If Text4.Text = vbNullString Or Val(Text4.Text) < 1 Then Text4.Text = "1"
- If Int(Text4.Text) > 1 Then Call Text1_Change
- End Sub
- Private Sub Text4_KeyPress(KeyAscii As Integer)
- If InIntOnly(KeyAscii) = False Then KeyAscii = 0
- End Sub
- Private Sub Text5_Change()
- Text6.Text = KBToAny(CboNameToNum(Combo2.Text), AnyToKB(CboNameToNum(Combo1.Text), Val(Text5.Text)))
- End Sub
- Private Sub Text5_KeyPress(KeyAscii As Integer)
- If InFloOnly(KeyAscii) = False Then KeyAscii = 0
- End Sub
- Private Sub VScroll1_Change(Index As Integer)
- Text2(Index).Text = VScroll1(Index).Value
- End Sub
复制代码
|
|