vb将字符串显示为二进制数据

10 篇文章 0 订阅
7 篇文章 0 订阅

vb将字符串显示为二进制数据

vb将字符串显示为二进制数据,这里主要使用向右移位操作,经过测试,移位操作符>>的移位时循环移位的,示例代码如下,在本示例中,尝试修改还可以观察到各种字符编码的宽度

Public Class Form1

   
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim thetest As Int16 = 3
        Dim thetest1 As UInt16 = 1
        Dim mystring As String = Nothing

        'thetest1 <<= 15  左移位
        'thetest1 = thetest1 * 2 - 2

        thetest1 = 1
        Dim myBytes() As Byte = System.Text.Encoding.UTF32.GetBytes("中托人")

        Dim thstring As String = Nothing

        Dim tt As Int32 = 0
        For tt = 0 To myBytes.Length - 1
            mystring = "+" + mystring
            Dim i As Int16 = 0
            While (i < 8)
                Dim theccd As UInt16 = myBytes(tt)
                theccd >>= i
                theccd = theccd And thetest1
                thstring = theccd.ToString

                mystring = thstring + mystring

                i += 1
            End While
            i = 0
            mystring = vbCrLf + mystring

        Next tt
        
        Label2.Text = mystring
       
    End Sub
End Class

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_40793198

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值