CodePudding user response:
In another post, reply, put in the form of a string converted to a string of large number of binary output,
Dim n As the Variant
Dim strOut As String
N=CDec (" 289356276212170752 ")
The Do While n & gt; 0
If the Int (n/2)=n/2 Then
StrOut="0" & amp; StrOut
The Else
StrOut="1" & amp; StrOut
End the If
N=Int (n/2)
Loop
MsgBox strOut
CodePudding user response:
Any number system conversion
'from decimal to arbitrary hexadecimal, Num to convert digital, NumS system value, hexadecimal, you can fill in 16, the return value is an array
Private Function FromDec (ByVal Num As Long, ByVal NumS As Integer) As an Integer ()
Dim C As an Integer, the Result () As an Integer
Do Until Num=0
ReDim Preserve the Result (C)
The Result (C)=Num Mod NumS
C=C + 1
Num=Num \ NumS
Loop
FromDec=Result
End the Function
'from arbitrary hexadecimal converted to decimal Num arbitrary hexadecimal number (), is an array, you can get used to a function, NumS or hexadecimal number, the return value is a decimal number
Private Function ToDec (ByRef Num () As an Integer, ByVal NumS As Integer) As Long
Dim I As an Integer, the Result As Long
For I=0 To UBound (Num)
Result=Result * + Num NumS (I)
Next
ToDec=Result
End the Function
'creating a hexadecimal string, Num is converted to arbitrary hexadecimal number, after is an array, NumStr the hexadecimal number sequence of symbols, such as hexadecimal sequence is 0123456789 abcdef, don't fill out (1) (2) the appearance of several
Private Function ShowValue (ByRef Num () As an Integer, Optional ByVal NumStr As String="") As String
Dim I As an Integer, the Result As a String
For I=0 To UBound (Num)
If Len (NumStr) & gt; 0 Then
Result=Mid (NumStr, Num (I) + 1, 1) & amp; The Result
The Else
Result="(" & amp; Num (I) & amp; ") "& amp; The Result
End the If
Next
ShowValue=https://bbs.csdn.net/topics/Result
End the Function
Private Sub Form_Load ()
Dim Arr () As an Integer
Arr=FromDec (634, 16) '634 into hexadecimal results stored in array Arr
The Debug. Print ShowValue (Arr, "abcdef" 0123456789) 'in the display array Arr hexadecimal number
Arr=FromDec (634, 2) '64 into 2 into the system results in the array Arr
The Debug. Print ShowValue (Arr, "01") '2 in a display array Arr hexadecimal number
End Sub
CodePudding user response:
An octal and hexadecimal binary wonderful methodCodePudding user response:
MSComm controlMSComm control through serial port transmit and receive data, provide the application with the serial communication function,
Syntax
MSComm
Description
MSComm control provides the following two kinds of processing way of communication:
Event-driven communication is To deal with the interactions of serial port, a very effective method in many cases, the need To be notified when events occur, for example, in a Carrier Detect (CD) or the Request To Send (RTS) online To a character or a change occurs, in these cases, can use MSComm control OnComm event capture and deal with the communication events, OnComm event can also check and deal with the communication error, a list of all communications events and communication error, refer To the CommEvent property,
After the procedure of each key function, can query by checking the value of the CommEvent property events and errors, if the application is lesser, and is the keep, this approach may be preferable, for example, if you write a simple telephone dial-up procedures, it should not be necessary to generate events for each receive a character, because the only waits to receive character is "sure" response of the modem,
Each using MSComm control corresponds to a serial port, if your application needs to access multiple serial port, must use more than one MSComm control that can be changed in the Windows "control panel" port address and interrupt address,
Although the MSComm control has many important properties, but first of all, must be familiar with several attributes,
Property description
CommPort set and returns the communication port number,
Settings set in the form of a string and returns the baud rate, parity, data bits, stop bits,
PortOpen set and returns the communication port state, also can open and close the port,
Input from the receive buffer and delete characters,
To transfer the Output buffer to write a string,