vb.net2进制转化 vb转换进制

用VB怎么把二进制转化为十进制

VB把二进制转化为十进制的方法:

创新互联公司主要从事网站设计、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务赤峰,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

' 用途:将二进制转化为十进制 ' 输入:Bin(二进制数) ' 输入数据类型:String

' 输出:BIN_to_DEC(十进制数) ' 输出数据类型:Long

' 输入的最大数为1111111111111111111111111111111(31个1),输出最大数为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

vb.net 将文件转化成二进制

首先引入System.IO命名空间

Imports System.IO

然后使用文件流来读入数组:

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就是整个文件的所有字节了

从字节生成Image:

Dim img As Image = Image.FromStream(New MemoryStream(bytes))

img就是图片了

vb.net 图片转换二进制代码

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

vb.net 中2、8、10、16进制转换代码怎么写

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 "选择的进制与数不符": 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://pwwzsj.com/article/ddosope.html