重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
'此函数用于十进制到二进制
10年积累的网站设计、网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先制作网站后付款的网站建设流程,更有神农架林区免费网站建设让你可以放心的选择与我们合作。
Private Function Bin(Number As Long) As Long
Dim Div_value As String
Do
Div_value = (Number Mod 2) Div_value
Number = Int(Number / 2)
Loop Until Number 2
Bin = Number Div_value
End Function
'此函数用于二进制到十进制
Private Function value_Bin(Number As Long) As Long
Dim Temp_value As Long, Cyc As Long
For Cyc = 0 To Len(Str(Number))
If Cyc = Len(Str(Number)) Then
value_Bin = Temp_value + Val(Mid(Str(Number), Cyc, 1))
Exit For
End If
If Cyc 0 Then Temp_value = (Temp_value + Val(Mid(Str(Number), Cyc, 1))) * 2
Next Cyc
End Function
'====写入以上函数后转值操作:
'十进制到十六进制:Hex(十进制数值)
'十进制到八进制:Oct(十进制数值)
'十进制到二进制:Bin(十进制数值)
'二进制到十进制:value_Bin(二进制数值)
'八进制到十进制:Val("O" 八进制数值)
'十六进制到十进制:Val("H" 十六进制数值)
比如
msgbox DEC_to_BIN(10)
就会返回一个10转换为十进制后的结果
或者简单点就用
VB自带函数:
十进制转八进制:Oct(num)
十六进制转八进制:oct("H" num)
十进制转十六进制:hex(num)
八进制转十六进制:hex("O" num)
十六进制转换为十进制
Dim str As String
str = Text2.Text
Text10.Text = CLng("H" str)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsgBox(DEC_to_HEX(255))
End Sub
Public Function DEC_to_HEX(ByVal 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
下面代码就是将文本框中以一个空格隔开的十六进制转为字节的代码,文本框中数字格式为:01 02 03
Dim TestArray() As String = Split(TextBox1.Text)
Dim hexBytes() As Byte
ReDim hexBytes(TestArray.Length - 1)
Dim i As Integer
For i = 0 To TestArray.Length - 1
hexBytes(i) = Val("h" TestArray(i))
Next
SerialPort.Write(hexBytes, 0, hexBytes.Length)
Dim s As String = "h" Hex(Asc(Val(InputBox("输入数值", "提示", 1))))
MsgBox(s)
#读取上次检查到的行数
last_line=`cat ./mailinfo`
echo "上次行数:"$last_line
#算出本次alert日志的行数
current_line=`wc -l $alert_log|awk '{print $1}'`
echo "本次行数:"$current_line
#取上次行数和本次行数之间的alert日志内容,然后把ORA错误及上下三行放到mailinfo中