请VB高手帮我写个计算机的源代码
老师给我布置了两个VB题目,二选一,题目在下面的链接。如果哪位会做的,请帮帮忙,小弟不胜感激!!!http://photo.store.qq.com/http_imglo...
老师给我布置了两个VB题目,二选一,题目在下面的链接。如果哪位会做的,请帮帮忙,小弟不胜感激!!!
http://photo.store.qq.com/http_imgload.cgi?/rurl2=875f7ff647a2a945fa5f8f05e9047be5457a1570d2b5d0c44e6741e41af18c068adc81c03dbe3efef53c73a5c5d78b14bea86485ef400179a3041031747e4f98c7793fa82f89555ac78bbe8a622820dab41d0e71 展开
http://photo.store.qq.com/http_imgload.cgi?/rurl2=875f7ff647a2a945fa5f8f05e9047be5457a1570d2b5d0c44e6741e41af18c068adc81c03dbe3efef53c73a5c5d78b14bea86485ef400179a3041031747e4f98c7793fa82f89555ac78bbe8a622820dab41d0e71 展开
4个回答
展开全部
'下面是一个按照你的上述要求制作的完整的进制转换文件,请把代码复制,并保存为文件Form1.Frm,然后双击此文件运行即可。
'==============Form1.Frm代码部分================
VERSION 5.00
Begin VB.Form Form1
Caption = "数制转换"
ClientHeight = 2805
ClientLeft = 60
ClientTop = 450
ClientWidth = 4710
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 2805
ScaleWidth = 4710
StartUpPosition = 3 '窗口缺省
Begin VB.OptionButton Option1
Caption = "16进制"
Height = 375
Index = 2
Left = 3000
TabIndex = 6
Top = 2040
Width = 1575
End
Begin VB.OptionButton Option1
Caption = "8进制"
Height = 375
Index = 1
Left = 1560
TabIndex = 5
Top = 2040
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "2进制"
Height = 375
Index = 0
Left = 120
TabIndex = 4
Top = 2040
Width = 1335
End
Begin VB.TextBox Text2
Height = 495
Left = 1800
TabIndex = 1
Top = 1080
Width = 2655
End
Begin VB.TextBox Text1
Height = 495
Left = 1800
TabIndex = 0
Top = 360
Width = 2655
End
Begin VB.Label Label2
Caption = "16进制数"
Height = 495
Left = 120
TabIndex = 3
Top = 1080
Width = 1575
End
Begin VB.Label Label1
Caption = "十进制数"
Height = 495
Left = 120
TabIndex = 2
Top = 360
Width = 1575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'下面是一个按照你的上述要求制作的完整的进制转换文件,请把代码复制,并保存为文件Form1.Frm,然后双击此文件运行即可。
'==============Form1.Frm代码部分================
Option Explicit
' 用途:将十进制转化为二 进 制
' 输入:Dec(十进制数)
' 输入数据类型:Long
' 输出:DEC_to_BIN(二 进 制数)
' 输出数据类型:String
' 输入的最大数为2147483647,输出最大数为1111111111111111111111111111111(31个1)
Public Function DEC_to_BIN(ByVal Dec As Long) As String
DEC_to_BIN = ""
Do While Dec > 0
DEC_to_BIN = Dec Mod 2 & DEC_to_BIN
Dec = Dec \ 2
Loop
End Function
' 用途:将十进制转化为十六进制
' 输入:Dec(十进制数)
' 输入数据类型:Long
' 输出:DEC_to_HEX(十六进制数)
' 输出数据类型:String
' 输入的最大数为2147483647,输出最大数为7FFFFFFF
Public Function DEC_to_HEX(Dec As Long) As String
Dim a As String
DEC_to_HEX = ""
Do While Dec > 0
a = CStr(Dec Mod 16)
Select Case a
Case "10": a = "A"
Case "11": a = "B"
Case "12": a = "C"
Case "13": a = "D"
Case "14": a = "E"
Case "15": a = "F"
End Select
DEC_to_HEX = a & DEC_to_HEX
Dec = Dec \ 16
Loop
End Function
' 用途:将十进制转化为八进制
' 输入:Dec(十进制数)
' 输入数据类型:Long
' 输出:DEC_to_OCT(八进制数)
' 输出数据类型:String
' 输入的最大数为2147483647,输出最大数为17777777777
Public Function DEC_to_OCT(ByVal Dec As Long) As String
DEC_to_OCT = ""
Do While Dec > 0
DEC_to_OCT = Dec Mod 8 & DEC_to_OCT
Dec = Dec \ 8
Loop
End Function
Private Sub Form_Load()
Text1.Text = "123"
End Sub
Private Sub Option1_Click(Index As Integer)
Dim S As String
S = Trim(Text1.Text)
Text2.Text = ""
If S = "" Then
MsgBox "请输入一个10进制数!"
Exit Sub
End If
Label2 = Option1(Index).Caption & "数"
Select Case Index
Case 0
Text2.Text = DEC_to_BIN(Val(S))
Case 1
Text2.Text = DEC_to_OCT(Val(S))
Case 2
Text2.Text = DEC_to_HEX(Val(S))
End Select
End Sub
'==============Form1.Frm代码部分================
VERSION 5.00
Begin VB.Form Form1
Caption = "数制转换"
ClientHeight = 2805
ClientLeft = 60
ClientTop = 450
ClientWidth = 4710
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 2805
ScaleWidth = 4710
StartUpPosition = 3 '窗口缺省
Begin VB.OptionButton Option1
Caption = "16进制"
Height = 375
Index = 2
Left = 3000
TabIndex = 6
Top = 2040
Width = 1575
End
Begin VB.OptionButton Option1
Caption = "8进制"
Height = 375
Index = 1
Left = 1560
TabIndex = 5
Top = 2040
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "2进制"
Height = 375
Index = 0
Left = 120
TabIndex = 4
Top = 2040
Width = 1335
End
Begin VB.TextBox Text2
Height = 495
Left = 1800
TabIndex = 1
Top = 1080
Width = 2655
End
Begin VB.TextBox Text1
Height = 495
Left = 1800
TabIndex = 0
Top = 360
Width = 2655
End
Begin VB.Label Label2
Caption = "16进制数"
Height = 495
Left = 120
TabIndex = 3
Top = 1080
Width = 1575
End
Begin VB.Label Label1
Caption = "十进制数"
Height = 495
Left = 120
TabIndex = 2
Top = 360
Width = 1575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'下面是一个按照你的上述要求制作的完整的进制转换文件,请把代码复制,并保存为文件Form1.Frm,然后双击此文件运行即可。
'==============Form1.Frm代码部分================
Option Explicit
' 用途:将十进制转化为二 进 制
' 输入:Dec(十进制数)
' 输入数据类型:Long
' 输出:DEC_to_BIN(二 进 制数)
' 输出数据类型:String
' 输入的最大数为2147483647,输出最大数为1111111111111111111111111111111(31个1)
Public Function DEC_to_BIN(ByVal Dec As Long) As String
DEC_to_BIN = ""
Do While Dec > 0
DEC_to_BIN = Dec Mod 2 & DEC_to_BIN
Dec = Dec \ 2
Loop
End Function
' 用途:将十进制转化为十六进制
' 输入:Dec(十进制数)
' 输入数据类型:Long
' 输出:DEC_to_HEX(十六进制数)
' 输出数据类型:String
' 输入的最大数为2147483647,输出最大数为7FFFFFFF
Public Function DEC_to_HEX(Dec As Long) As String
Dim a As String
DEC_to_HEX = ""
Do While Dec > 0
a = CStr(Dec Mod 16)
Select Case a
Case "10": a = "A"
Case "11": a = "B"
Case "12": a = "C"
Case "13": a = "D"
Case "14": a = "E"
Case "15": a = "F"
End Select
DEC_to_HEX = a & DEC_to_HEX
Dec = Dec \ 16
Loop
End Function
' 用途:将十进制转化为八进制
' 输入:Dec(十进制数)
' 输入数据类型:Long
' 输出:DEC_to_OCT(八进制数)
' 输出数据类型:String
' 输入的最大数为2147483647,输出最大数为17777777777
Public Function DEC_to_OCT(ByVal Dec As Long) As String
DEC_to_OCT = ""
Do While Dec > 0
DEC_to_OCT = Dec Mod 8 & DEC_to_OCT
Dec = Dec \ 8
Loop
End Function
Private Sub Form_Load()
Text1.Text = "123"
End Sub
Private Sub Option1_Click(Index As Integer)
Dim S As String
S = Trim(Text1.Text)
Text2.Text = ""
If S = "" Then
MsgBox "请输入一个10进制数!"
Exit Sub
End If
Label2 = Option1(Index).Caption & "数"
Select Case Index
Case 0
Text2.Text = DEC_to_BIN(Val(S))
Case 1
Text2.Text = DEC_to_OCT(Val(S))
Case 2
Text2.Text = DEC_to_HEX(Val(S))
End Select
End Sub
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
展开全部
看不到图片
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
很简单,呵呵,你们老师有什么额外要求没有,就是变量格式...
提高一点分数的话,我接了
提高一点分数的话,我接了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
第2个要转换小数么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询