VB.net -32768〜32767これは16ビットのバイナリ文字列に変換されます



Vb Net 32768 32767 Which Will Be Converted 16 Bit Binary String



'Acquires the corresponding position and type of data by the short bit number (from 0-15) state (ON or OFF) Public Function Gsz_short_To_bite(ByVal Gsz_Short As Short, ByVal Gsz_weihao As Integer) As Boolean Dim Gsz_String_YuanShi_ErJinZhi As String Dim Gsz_String_YuanShi_GaoWeiBuLing As String Dim Gsz_String_YuanShi_GaoWeiBuLing_DaoXu As String Dim Gsz_Status As Boolean Try If Gsz_Short >= -32768 And Gsz_Short <= 32767 Then Gsz_String_YuanShi_ErJinZhi = Convert.ToString (Gsz_Short, 2) 'the decimal (positive or negative binary conversion) Gsz_String_YuanShi_GaoWeiBuLing = Strings.Right ( '0000000000000000' & Gsz_String_YuanShi_ErJinZhi, 16) 'zero padding Gsz_String_YuanShi_GaoWeiBuLing_DaoXu = StrReverse (Gsz_String_YuanShi_GaoWeiBuLing) 'reverse If Gsz_String_YuanShi_GaoWeiBuLing_DaoXu.Substring(Gsz_weihao, 1) = '1' Then Gsz_Status = True Gsz_LastEventAdd ( 'status bit corresponding to: ON :::' & Gsz_String_YuanShi_GaoWeiBuLing_DaoXu) Else Gsz_Status = False Gsz_LastEventAdd ( 'the corresponding bit status: OFF :::' & Gsz_String_YuanShi_GaoWeiBuLing_DaoXu) End If Else End If Catch ex As Exception MessageBox.Show(ex.Message) End Try Return Gsz_Status End Function