Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
目前成都創(chuàng)新互聯(lián)公司已為上千的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站運(yùn)營、企業(yè)網(wǎng)站設(shè)計(jì)、東山網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
Dim?X2?As?Integer?=?0
Dim?Y2?As?Integer?=?0
Dim?X3?As?Integer?=?2
Dim?Y3?As?Integer?=?-1
Dim?X4?As?Integer?=?6
Dim?Y4?As?Integer?=?3
'首先計(jì)算y=kx+b
Dim?k?As?Double?=?(6?-?2)?/?(3?-?(-1))
Dim?b?As?Double?=?-1?-?k?*?2
'根據(jù)y求x
Dim?X5?As?Double?=?-b?/?k
TextBox1.Text?=?Math.Abs(X5?-?X2)
End?Sub
不是很明白你的題意
strHex = strHex + [String].Format("{0:X2} "
這里的意思是把每個(gè)字節(jié)數(shù)據(jù)轉(zhuǎn)換成了十六進(jìn)制,每個(gè)字節(jié)占兩個(gè)字符
如果你串口收到的4個(gè)字節(jié)數(shù)據(jù):43,27,56,200
那么你的結(jié)果是:2B1B38C8
即receivebytes.Text="2B1B38C8"
不足兩位的補(bǔ)0
如果你串口收到的4個(gè)字節(jié)數(shù)據(jù):3,27,56,200
那么你的結(jié)果是:031B38C8
即receivebytes.Text="031B38C8"
Dim x(8, 8)
Dim a As Integer
Dim b As Integer
b = 0
For i = 0 To 8
For j = 0 To 8
If b = 3 Then
b = 1
a = a + 1
Else
b = b + 1
End If
x(i, j) = aNext
Next
下面是完整的類,可以設(shè)置任意密碼
'DES及md5加密解密----添加引用中添加對system.web的引用。
Imports?System.Security.Cryptography
Imports?System
Imports?System.Text
Imports?System.Web
'''?summary
'''?DES加密類
'''?/summary
'''?remarks/remarks
Public?Class?DESEncrypt
Public?Sub?DESEncrypt()
End?Sub
Public?Shared?Function?Encrypt(ByVal?Text?As?String)?As?String
Return?Encrypt(Text,?"12345678")
End?Function
Public?Shared?Function?Encrypt(ByVal?Text?As?String,?ByVal?sKey?As?String)?As?String
Dim?des?As?New?DESCryptoServiceProvider()
Dim?inputByteArray?As?Byte()
inputByteArray?=?Encoding.Default.GetBytes(Text)
des.Key?=?ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey,?"md5").Substring(0,?8))
des.IV?=?ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey,?"md5").Substring(0,?8))
Dim?ms?As?New?System.IO.MemoryStream()
Dim?cs?As?New?CryptoStream(ms,?des.CreateEncryptor(),?CryptoStreamMode.Write)
cs.Write(inputByteArray,?0,?inputByteArray.Length)
cs.FlushFinalBlock()
Dim?ret?As?New?StringBuilder()
Dim?b?As?Byte
For?Each?b?In?ms.ToArray()
ret.AppendFormat("{0:X2}",?b)
Next
Return?ret.ToString()
End?Function
Public?Shared?Function?Decrypt(ByVal?Text?As?String)?As?String
Return?Decrypt(Text,?"12345678")
End?Function
Public?Shared?Function?Decrypt(ByVal?Text?As?String,?ByVal?sKey?As?String)?As?String
Dim?des?As?New?DESCryptoServiceProvider()
Dim?len?As?Integer
len?=?Text.Length?/?2
Dim?inputByteArray(len?-?1)?As?Byte
Dim?x,?i?As?Integer
For?x?=?0?To?len?-?1
i?=?Convert.ToInt32(Text.Substring(x?*?2,?2),?16)
inputByteArray(x)?=?CType(i,?Byte)
Next
des.Key?=?ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey,?"md5").Substring(0,?8))
des.IV?=?ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey,?"md5").Substring(0,?8))
Dim?ms?As?New?System.IO.MemoryStream()
Dim?cs?As?New?CryptoStream(ms,?des.CreateDecryptor(),?CryptoStreamMode.Write)
cs.Write(inputByteArray,?0,?inputByteArray.Length)
cs.FlushFinalBlock()
Return?Encoding.Default.GetString(ms.ToArray())
End?Function
End?Class
'以下是調(diào)用方法
Public?Class?Form1
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click?'加密
Dim?str_Encrypt?As?String?=?DESEncrypt.Encrypt("你要加密的文本,可以是任意長度",?"密碼,可以很長,如果省略這個(gè)參數(shù)就是默認(rèn)的12345678")
End?Sub
Private?Sub?Button2_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button2.Click?'解密
Dim?str_Decrypt?As?String?=?DESEncrypt.Decrypt("你要解密的文本,?可以是任意長度",?"加密時(shí)用到的密碼,如果省略這個(gè)參數(shù)就是默認(rèn)的12345678")
End?Sub
scale(x1,y1)-(x2,y2)
你只要記住,這里的x1,y1是左上角的坐標(biāo),x2,y2是右下角的坐標(biāo),通過這兩個(gè)點(diǎn)的坐標(biāo)設(shè)定,就可以決定坐標(biāo)原點(diǎn)的位置以及坐標(biāo)軸的方向了,比如
Scale (-300,200)-(300,-200)
以上是把坐標(biāo)原點(diǎn)設(shè)在窗體中心,x軸長600,方向從左到右,y軸長400,方向從下向上。
Scale (800,0)-(0,600)
以上是把坐標(biāo)原點(diǎn)設(shè)在窗體右上角,x軸長800,方向從右到左,y軸長600,方向從上向下。
下面說坐標(biāo)軸和原點(diǎn)的標(biāo)示法:
假定自定義坐標(biāo)設(shè)為:
Scale (-300, 200)-(300, -200)
則
Line (-300, 0)-(300, 0) '畫x軸
Line (0, 200)-(0, -200) '畫y軸
CurrentX = 290
CurrentY = -5
Print "x" '標(biāo)示x軸
CurrentX = 5
CurrentY = 200
Print "y" '標(biāo)示y軸
CurrentX = 5
CurrentY = -5
Print "0" '標(biāo)示原點(diǎn)