VB把二進制轉化為十進制的方法:
創(chuàng)新互聯(lián)公司主要從事網(wǎng)站設計、成都網(wǎng)站建設、網(wǎng)頁設計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務。立足成都服務赤峰,10多年網(wǎng)站建設經(jīng)驗,價格優(yōu)惠、服務專業(yè),歡迎來電咨詢建站服務:18980820575
' 用途:將二進制轉化為十進制 ' 輸入:Bin(二進制數(shù)) ' 輸入數(shù)據(jù)類型:String
' 輸出:BIN_to_DEC(十進制數(shù)) ' 輸出數(shù)據(jù)類型:Long
' 輸入的最大數(shù)為1111111111111111111111111111111(31個1),輸出最大數(shù)為2147483647
Public Function BIN_to_DEC(ByVal Bin As String) As Long Dim i As Long
For i = 1 To Len(Bin)
BIN_to_DEC = BIN_to_DEC * 2 + Val(Mid(Bin, i, 1)) Next i
End Function
比如輸入:1010
輸出就是:10
首先引入System.IO命名空間
Imports System.IO
然后使用文件流來讀入數(shù)組:
Dim bytes() As Byte
Using fs As New FileStream(文件路徑,FileMode.Open)
ReDim bytes(fs.Length-1)
fs.Read(bytes,0,fs.Length)
fs.Close()
End Using
這樣bytes就是整個文件的所有字節(jié)了
從字節(jié)生成Image:
Dim img As Image = Image.FromStream(New MemoryStream(bytes))
img就是圖片了
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyStream As New System.IO.MemoryStream
Me.PictureBox1.Image.Save(MyStream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim MyBytes(MyStream.Length) As Byte
MyStream.Read(MyBytes, 0, MyStream.Length)
MyStream.Close()
Dim strText As String
strText = BitConverter.ToString(MyBytes)
Me.TextBox1.Text = strText
End Sub
Option Explicit
Dim Jz As Integer, K As Boolean
Private Sub Command1_Click()
Pic.Cls
If K Then Jz = Val(Qtjz.Text)
If Pd(Text1.Text, Jz) Then Pic.Print "選擇的進制與數(shù)不符": Exit Sub
If Jz = 0 Then Pic.Print "請先輸入進制" Else Pic.Print Zh(Text1.Text, Jz)
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
Private Sub Option1_Click(Index As Integer)
K = False
Select Case Index
Case 0
Jz = 2
Case 1
Jz = 8
Case 2
Jz = 10
Case 3
Jz = 16
Case 4
K = True
Qtjz.Text = ""
Qtjz.SetFocus
End Select
If Index 4 Then Command1.SetFocus
End Sub
Private Sub Qtjz_Click()
Qtjz.Text = ""
End Sub
Private Sub Text1_Click()
Text1.Text = ""
End Sub
Private Function Zh(a As String, b As Integer) As Integer
Dim c As String, i, d As Integer
a = LCase(a)
For i = 1 To Len(a)
c = Mid(a, Len(a) + 1 - i, 1)
If Asc(c) 96 Then d = Asc(c) - 87 Else d = Val(c)
Zh = Zh + d * b ^ (i - 1)
Next i
End Function
Private Function Pd(a As String, b As Integer) As Boolean
Dim c As String, i, d As Integer
Pd = False
For i = 1 To Len(a)
c = Mid(a, Len(a) + 1 - i, 1)
If Asc(c) 96 Then d = Asc(c) - 87 Else d = Val(c)
If d b - 1 Then Pd = True: Exit Function
Next i
End Function
文章題目:vb.net2進制轉化 vb轉換進制
本文鏈接:http://chinadenli.net/article34/ddosope.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信公眾號、外貿建站、網(wǎng)站改版、虛擬主機、商城網(wǎng)站、全網(wǎng)營銷推廣
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)