如果有人知道VISUAL BASIC,请帮帮我吗? [英] Please help me if anyone know VISUAL BASIC?

查看:87
本文介绍了如果有人知道VISUAL BASIC,请帮帮我吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想压缩二进制数据。

假设我有两个二进制值01000100和01000010.

我想像这样压缩它们:

I want to compress binary data.
Suppose i have two binary values 01000100 and 01000010.
I want to compress them like this:

01000100 = 1
01000010 = 0



压缩后2bytes将转换为2bits

并将它们解压缩如下:


After compress the 2bytes would be converted to 2bits
and decompress them like:

1 = 01000100
0 = 01000010



解压缩后,2bits将转换为2bytes



实际上我想将2byte(二进制)压缩为2bits.And解压后再次将数据转换为2byte。 />
我如何在visual basic中完成它。我是计算机编程的新手


After decompress the 2bits would be converted to 2bytes

Actually i want to compress 2byte(binary) to 2bits.And after decompress the data again convert to 2byte.
How can i do it in visual basic. I am a new in computer programming

推荐答案

Function CompressText (ByVal TextToCompress as String) As Integer
If TextToCompress = "01000100" Then Return 1
If TextToCompress = "01000010" Then Return 0
End Function

Function DeCompressText (ByVal TextToDeCompress as String) As String
If TextToDeCompress = 1 Then Return "01000100" 
If TextToDeCompress = 0 Then Return "01000010"
End Function

'Call Above Function When-ever and Where-ever it Necessary...
'Example:
'TextBox1.Text = DeCompressText(1)
'TextBox2.Text = CompressText("01000100")


使用内置Visual Basic函数甚至用户定义函数都无法执行该操作(除非你有自己的算法),如果你有自己的逻辑,那么考虑用你的算法改进你的解决方案。



但是在我的观点,你得到的是256(2 ^ 8)二进制值,使用8个0和1。



然后你将如何合并这些256个值只有2个值?



如果需要将二进制值转换为十进制或十六进制值?回复此解决方案,我会帮助...
You can''t Perform That Operation, With Build-in Visual Basic Function and even User Defined Function (unless you have your Very own Algorithm), If you have Your Very Own Logic on this Then Consider Improving Your Solution with Your Algorithm.

But in My Opinion, There are 256 (2^8) Binary Value you get using 8 Set of 0 and 1.

Then How will you consolidate these 256 Values with only 2 Value?

If You need to Convert Binary Value into Decimal or HexaDecimal Value? Reply to This Solution, I''ll Help...


您无法执行该操作,具有内置Visual Basic功能甚至用户定义功能(除非您有非常自己的算法),如果你有你自己的逻辑然后考虑用你的算法改进你的解决方案。



但在我的意见中,有256(2 ^ 8)使用8 Set 0和1得到的二进制值。



那么如何将这256个值合并为2个值?



如果需要将二进制值转换为十进制或十六进制值?回复此解决方案,我会帮助...
you can''t Perform That Operation, With Build-in Visual Basic Function and even User Defined Function (unless you have your Very own Algorithm), If you have Your Very Own Logic on this Then Consider Improving Your Solution with Your Algorithm.

But in My Opinion, There are 256 (2^8) Binary Value you get using 8 Set of 0 and 1.

Then How will you consolidate these 256 Values with only 2 Value?

If You need to Convert Binary Value into Decimal or HexaDecimal Value? Reply to This Solution, I''ll Help...


这篇关于如果有人知道VISUAL BASIC,请帮帮我吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆