VB中二进制八进制十进制十六进制的符
VB中二进制 八进制 十进制 十六进制的符号怎么表示
二进制 Binary
八进制 octal
十进制 decimal
十六进制 hexadecimal
单词 第一个 字母 就可以了!
呵呵
VB中的八进制怎么算
Oct 函数
返回 Variant (String),代表一数值的八进制值。
语法
Oct(number)
必要的 number 参数为任何有效的数值表达式或字符串表达式。
说明
如果 number 尚非整数,那么在执行前会先四舍五入成最接近的整数。
如果 number 为 Oct 返回
Null Null
Empty 零 (0)
任何其他的数字 最多可到 11 个八进制字符。
可以将适当范围的数前缀以 &O 来直接表示八进制数字。例如,八进制表示法的 &O10 代表十进制的 8。
Oct 函数示例
本示例使用 Oct 函数将某数值转换为 8 进制表达式。
Dim MyOct
MyOct = Oct(4) ' 返回 4。
MyOct = Oct(8) ' 返回 10。
MyOct = Oct(459) ' 返回 713。
vb中怎么编写判断一个数是不是八进制数
请参考
Private Sub Command1_Click()
Text2 = ReadOctal(Text1)
End Sub
Private Sub Command2_Click()
Text1 = WriteOctal(Text2)
End Sub
Function ReadOctal(num As String)
For i = 1 To Len(num)
s = Val(Mid(num, i, 1))
If s > 7 Then MsgBox "八进制数中不能有大于7的数字!": Exit Function
ReadOctal = ReadOctal * 8 + s
Next
End Function
Function WriteOctal(num As String)
Dim a%(10), m%, i%
s = ""
m = num
i = 0
Do While m 0
a(i) = m Mod 2
m = m \ 2
i = i + 1
Loop
For k = i - 1 To 0 Step -1
s = s & a(k)
Next
i = Len(s) Mod 3
Select Case i
Case 1: s = "00" & s
Case 2: s = "0" & s
End Select
For i = 1 To Len(s) Step 3
s1 = Mid(s, i, 3)
s2 = 0
For j = 1 To 3
s2 = s2 * 2 + Val(Mid(s1, j, 1))
Next
WriteOctal = WriteOctal & s2
Next
End Function
求 vb 八进制转化为二进制的代码
用途:将八进制转化为二进制
输入:Oct(八进制数)
输入数据类型:String
输出:OCT_to_BIN(二进制数)
输出数据类型:String
输入的最大数为2147483647个字符
Public OCT_to_BIN(ByVal Oct As String) As String
Dim i As Long
Dim B As String
For i = 1 To Len(Oct)
Select Case Mid(Oct, i, 1)
Case "0": B = B & "000"
Case "1": B = B & "001"
Case "2": B = B & "010"
Case "3": B = B & "011"
Case "4": B = B & "100"
Case "5": B = B & "101"
Case "6": B = B & "110"
Case "7": B = B & "111"
End Select
Next i
While Left(B, 1) = "0"
B = Right(B, Len(B) - 1)
Wend
OCT_to_BIN = B
End
十进制转化为八进制的vb代码
代码: Private Sub Command1_Click()
Dim x As Long
x = Val(InputBox("请输入一个十进制数:"))
Print "转换为八进制的结果是: ", Str(DEC_to_OCT(x))
End Sub
Public Function DEC_to_OCT(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 图:
VB编程,输入一个八进制数,转换成为十进制数的子过程。
Private Sub Form_Click()
Dim N As String, S As Double
N = InputBox("请输入一个8进制数")
For i = Len(N) To 1 Step -1
S = S + 8 ^ Val(Len(N) - i) * Val(Mid(N, i, 1))
Next
Print S
End Sub
VB高手用VB编写八进制和十进制数
Private Sub Command1_Click()
Text2 = ReadOctal(Text1)
End Sub
Private Sub Command2_Click()
Text1 = WriteOctal(Text2)
End Sub
Function ReadOctal(num As String)
For i = 1 To Len(num)
s = Val(Mid(num, i, 1))
If s > 7 Then MsgBox "八进制数中不能有大于7的数字!": Exit Function
ReadOctal = ReadOctal * 8 + s
Next
End Function
Function WriteOctal(num As String)
Dim a%(10), m%, i%
s = ""
m = num
i = 0
Do While m 0
a(i) = m Mod 2
m = m \ 2
i = i + 1
Loop
For k = i - 1 To 0 Step -1
s = s & a(k)
Next
i = Len(s) Mod 3
Select Case i
Case 1: s = "00" & s
Case 2: s = "0" & s
End Select
For i = 1 To Len(s) Step 3
s1 = Mid(s, i, 3)
s2 = 0
For j = 1 To 3
s2 = s2 * 2 + Val(Mid(s1, j, 1))
Next
WriteOctal = WriteOctal & s2
Next
End Function
请采纳
VB编程十进制转八进制,具体怎么写,作业快交了,急
Private Sub Form_Click()
Dim N As String, S As Double
N = InputBox("请输入一个8进制数")
For i = Len(N) To 1 Step -1
S = S + 8 ^ Val(Len(N) - i) * Val(Mid(N, i, 1))
Next
Print S
End Sub
麻烦帮忙用VB做一个十进制转换为二进制,八进制,十六进制的程序。图片如下
...........................可以帮你。
VB中八进制转换十进制
第一种:如果知道所转换的十进制值的类型的的直接使用CBool, CByte, CCur, CDate, CDbl, CDec, CInt, CLng, CSng, CStr, CVar, CVErr等强制转化类型比如
把八进制的11转化为十进制的integer类型的话是字节长度为16的9
转发方法是debug.print cint(“&011”)
你将会在调试窗口中看到9明白没?
第二种:笨办法,例如八进制abcd转换十进制是
a*8^3+b*8^2+c*8+d
VB中二进制八进制十进制十六进制的符:等您坐沙发呢!