Byte Swap Little Endian To Double
I have a 8 byte buffer and I need to convert it to a "Double". It's in little endian format. I need to know how to convert it using 8 bytes. I NEED HELP!!!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Swap Endian Function For Integer
My function to convert big endian to little endian is wrong.
Public Function SwapEndianInteger(ByVal w As Integer) As Long
' converts Big Endian Word to Little Endian Word
CopyMemory ByVal VarPtr(SwapEndianInteger), ByVal VarPtr(w) + 1, 1
CopyMemory SwapEndianInteger, ByVal VarPtr(w) + 1, 1
Can someone tell me what I am doing wrong?
Little Endian To Double
I have a byte buffer with 8 bytes. The bytes are in little endian format and I need to convert the byte buffer to a Double IEEE Standard 754. Need help on this conversion!!!
Little Endian Unicode, Byte Arrays And B Strings
I have had a lot of problems handling Byte Arrays and turning them into strings which can be worked on with VB. This has been compounded by coming across Unicode strings in both Little Endian and Big Endian format. I have now managed to make all this work ( sweated blood for days ) so some people may find the following useful.
Firstly, we are all familiar with strings stored in ANSI so if you write
strThing = "AB"
and examine it in a Hex Editor you will see 4142 ( 6566 in decimal ) as you would expect. So how do the Chinese manage? Well, the answer of course is that instead of using 256 bytes they use Unicode which has 256 X 256 ( ie 65536 bytes ) So if you write ( these are Chinese chars but may appear as a row of question marks depending on your fonts or something! )
strThing = "テン"
and examine it in a Hex Editor you will see C630F330 ( edit - needless to say having saved the html file from the site I see something totally different but we knew that would happen didn't we ) . I know that because I am preparing this document on Word Pad and just saved it using the "Unicode Text Document" option and then opened it using the AXE ( http://www.jbrowse.com/products/axe/ ) hex editor. It seems that Windows uses Little Endian Unicode where the Least Significant Byte comes first whereas Java uses big-endian where the Most Significant Byte comes first. Having said that it appears that VB works with Big Endian but is baffled by Little Endian - go figure. If you check this file in a hex editor you ( should ) see that the file starts with FFFE which signifies Little Endian format. Big Endian would start with FEFF although I believe that if there is nothing there then it is default Big Endian ( I may be wrong about that though )
Visual Basic takes care of most of this stuff so unlike C programmers we can all ignore it most of the time. The problem comes when you can't. My specific problem was that I have a routine that downloads net files which may or may not be text files in binary which I then need to convert to a text file ( I could download as a text file but for other reasons wanted to download everything as binary ) Now in theory you can use the StrConv function provided as standard in VB. If you press F1 you will find the following helpful statement "When you're converting from a Byte array in ANSI format to a string, you should use the StrConv function. When you're converting from such an array in Unicode format, use an assignment statement" My problem is that I did not know the format until I had done the conversion. Anyway, I eventually found an extremely useful site: http://www.mvps.org/vb/hardcore/html/whatisunicode.htm
From this I developed code which works
Dim bytBuffer() As Byte
Dim strBuffer As String
bytBuffer = inet.GetChunk(1024, icByteArray)
strBuffer = bytBuffer 'The assignment - important step
Is the string found Little Endian?
Public Function LittleEndianFound(strBuffer As String) As Boolean
If Hex(IntegerFromStrB(strBuffer, 1)) = "FF" And Hex(IntegerFromStrB(strBuffer, 2)) = "FE" Then
LittleEndianFound = True
LittleEndianFound = False
This is how we found out
Public Function IntegerFromStrB(strBuffer As String, lngOffset As Long) As Integer
Dim lngThing As Long
lngThing = AscB(MidB$(strBuffer, lngOffset, 1))
'Do data conversion tricks to turn the unsigned character into a signed Basic integer
If lngThing And &H8000& Then
IntegerFromStrB = lngThing Or &HFFFF000
IntegerFromStrB = lngThing And &HFFFF&
Public Function ConvertLittleEndianString(strBuffer As String) As String
'It is "Little Endian" Unicode so needs changing into "Big Endian" Unicode
Dim lngCnt As Long
For lngCnt = 3 To LenB(strBuffer) Step 2
ConvertLittleEndianString = ConvertLittleEndianString & Chr(IntegerFromStrB(strBuffer, lngCnt))
This code is now in my routine and works which is the ultimate test as far as I am concerned!
Bit Swap Within A Byte
I need to take an 8 bit word and switch the order of the bits, this isn't an endian change. More like a mirror image of the byte.
It is only 8 bits making b0 = b7, b1 = b6... etc
Is there an algorithm out there, I can think of some brute force methods. But I'm looking for something not as time consuming as these brute force possibilities because I have to do this alot, constantly.
I'm using this code, but is there a way to double the size of a byte? (so: 2 bytes)
Private Type DataRead
leagueid As Byte
space1 As Byte
teamid As Byte
space2 As Byte
Have been searching on the forums and MSDN, but couldn't find anything. I want something to read leagueid and space1 in one thing. In my hex editor the value is "3203", but when reading teamid out of the file it only gives the first part "32".
0100 0000 0D01 0000
0100 0000 0F01 0000
0100 0000 1001 0000
0100 0000 3203 0000
0100 0000 3303 0000
0100 0000 3403 0000
0100 0000 3A03 0000
0100 0000 A205 0000
0100 0000 A305 0000
0100 0000 A505 0000
0100 0000 EC05 0000
0100 0000 FC06 0000
Sorry for my poor English, but what I want is this:
- first column = leagueid
- second column (0000) = space1
- third column = teamid
- fourth column = space2
Greetings and thanks in advance!
Get Byte From Double Value
I have one double value. From that double value i want to get byte by byte data. but when i tried to do it it is giving me overflow error? is any body know How to do that??
dim dblval as double
dim bytval as byte
bytval= dblval and 255
it is giving me overflow error at this point.
Reply me ASAP.
Byte Arrays To Double
How would you take 8 elements of an byte array and place them in a double datatype.
I have 8 elements of a byte array from a telemetry packet that make a whole double not sure how to combine them.
Can VB6 show captions and menus for "double-byte languages" such as Chinese, Japanese etc?
Double Byte Character
I am looking for some VB example on Double byte character (Not Unicode) for international language. Are there any good site?
Byte() Buffer To Double
Here is the byte() buffer that I have:
byte(0) = 0xDB
byte(1) = 0xDD
byte(2) = 0X6C
byte(3) = 0x0A
byte(4) = 0x3A
byte(5) = 0xC6
byte(6) = 0xE6
byte(7) = 0x3F
Need to convert this byte buffer into a 64 bit ANSI/IEEE std 754 IEEE floating point number
Anyone out there no how to do this???
Double Byte Characters In VB
Is there any way to restrict the text in a VB text box to only single byte characters, so that the user is not able to enter any double byte characters.
This is very urgent.
Thanks in advance.
Dir$ And Double-Byte Character Filenames
I am doing a recursive search of folders and files (that thing that I picked up here is brilliant! Thank you )... but I have some Japanese files and folders. It gives me an "Invalid Filename" runtime error when I run the program.
Thanks in advance.
Double Byte Codes In Excel
I have a spreadsheet with mandarin characters in it. These characters (words) are stored as double byte binary codes. I want to retrieve these codes in thier raw format.
Every attempt I have tried so far has seen them be converted to ascii text.
Double-Byte Encoding Conversion
I'm currently in the middle of building a multi-language software which communicates with a machine which spits out data (in bytes) through USB port.
To process the data, I need to convert the data to char type. It seems like the value that I'm getting when using Windows XP with the regional settings set to English is different when I set it to Chinese(traditional).
I've searched the web and I found out that the 2 languages using different encodings (chinese using double byte encoding where 2 bytes represents 1 characters while english use one byte to represent 1 characters).
Is there anyone knows how to convert between the 2 encodings in Visual Basic 6 or have different approach how to get the same value from the 2 encodings? Thanks.
Double-byte Chars In Word Macro(?)
I'm not sure which forum i should ask this question in, but here goes. You'll probably wonder why I need to know this, it's to write the VB portion of a camputer-aided translation program.
Anyway, I'm working on a macro in Word which reads a Word file line by line and write it to a text file. Simple enough, until I had to use it on files written in Chinese. Then I started getting error messages.
Anybody know how to enable VB to output double-byte strings in Asian langs? Microsoft says that VB can't do this but hints that there are some workarounds. I've considered their IPDK but don't know if that does it.
Here is some sample code:
Sub Chi2TXT() ' not real name
Dim fso, txtfil, chidir, unidir, chichar, unichar
chidir = InputBox("Please type the full path and filename of the TXT output file", "Enter Glossary Path and Filename", "c:"
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfil = fso.OpenTextFile(chidir, 2, True)
Selection.HomeKey Unit:=wdStory, Extend:=wdMove
x = 0
y = ActiveDocument.BuiltInDocumentProperties("Number of Lines")
Do Until x = y 'do as many times as there are lines in the active doc
chiline = Selection
uniline = StrConv(chiline, vbUnicode, [LocaleID])
'little help with LocaleID? Don't know which to use.
x = x + 1
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdMove
Simple enough. I don;t use WriteLine to write UNILINE because it turns the chinese back to ANSI format. But when I do use it to insert a paragraph mark it displays that mark as a strange Unicode char (at the beginning of each line except the first) which messes up the display. If I eliminate it, the rest displays correctly.
But is there a way to FULLY enable VB to work with double-byte so I can stop doing all these tricks? I need to make other macros and this workaround might not solve all my problems.
Does VB 6 Support Double Byte Asian Languages?
I have a scenario that I'm hoping to see if anyone has come across this. Basically, we wrote an app in VB6 at work. Everything had been tested in regular English Win XP and Vista and confirmed that it's working fine. This app was then installed in Korea, with the Korean version of Windows OS. It was just reported to us that it's not working at all.
Well to make it short, in our code, we have to communicate to a proprietary USB device. The USB communication chip that we purchased retrieves the input buffer from the USB port as a type string. We then depend on the ASC() function and Chr() in VB 6 a lot to do the parsing of the input buffer. Well, ASC() and Chr() work fine in single byte languages, but we just confirmed that they do not work for double byte asian languages, in this case Korean.
Has any one here come across this problem in the past? The thing that I can't understand is that for example: a character of ASCII code 128, if you run this through the ASC() function, in single byte language systems, it should give you back the value of 128. However, I have noticed that in a double byte language system, it gave me a really strange value of -23834. How can this happen?
If you have any thoughts on this, I really appreciate your help.
Taking Double-Byte Into VB 6 Then Back Out Into SQL Server
I'm trying to take Excel spreadsheets with data in a few different languages (English and Japanese at least), read, parse, and error check them in VB 6, then write to SQL Server 2000 in unicode (to support double-byte characters). However, I am having issues pulling in double-byte from the spreadsheets into VB 6 and having VB recognize the characters (it currently displays question marks). I've looked at the knowledge base and can see that controls can be used for allowing double-byte entry into a VB app and handling it, however my app should run behind the scenes to just process files and will need no controls such as textboxes. Does anyone have any ideas of how I can do this? Right now, I'm developing on Windows 2000, and have loaded the Japanese language pack to no avail.
Can You Do The Reverse Conversion Of 8 Byte Array -> Vba Double.
I have a function which converts an 8 byte array (read in from a cobol program) into a double value in VBA. It works.
Do you know how to do the reverse, i.e. take a VB value and convert it into the 8 byte array representation?
I am stumped. Any hints you may have would be greatly appreciated.
Here is the function which converts 8 byte array into a double value.
'DOUBLE CONVERSION SUPPORT
Function cv8ByteArrayToDouble(Bytes As Variant, ByRef d As Double) As Boolean
' Please note - bytes are number 1 - 8 and bits in each byte start at 1 and go to 8.
Dim dImpliedMantissa As Double
Dim lBiasedExponent As Long
Dim lSignOfMantissa As Long
If (Not UBound(Bytes) - LBound(Bytes) + 1) = 8 Then
dImpliedMantissa = 0
lBiasedExponent = 0
lSignOfMantissa = 1 ' Assuming bit in 64th position is 0 (and SignOfMantissa of ImpliedMantissa is positive)
cv8ByteArrayToDouble = True
' (A) Check if ImpliedMantissa is negative
If (Bytes(1) And CByte(128)) > 0 Then
lSignOfMantissa = -1
' Debug.Print "Sign of Implied Mantissa: " & lSignOfMantissa
' (B) Get the value of the BiasedExponent (valueofbits-fixed value of 1023)
' Start at bit 5 of bytes(2) and goto bit 7 of bytes(1)
Dim lByteCtr As Long
Dim lByteFrom As Long
For lByteCtr = 5 To 8
If (CByte((2 ^ (lByteCtr - 1))) And Bytes(2)) > 0 Then
lBiasedExponent = lBiasedExponent + 2 ^ (lByteCtr - 5)
For lByteCtr = 1 To 7
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(1)) > 0 Then
lBiasedExponent = lBiasedExponent + 2 ^ (lByteCtr + 3)
lBiasedExponent = lBiasedExponent - 1023
' Debug.Print "Biased Exponent: " & lBiasedExponent
' (C) Get the value of the Implied Mantissa (1+(Value of binary fraction))
For lByteCtr = 4 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(2)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr - 4)))
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(3)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 4)))
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(4)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 12)))
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(5)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 20)))
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(6)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 28)))
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(7)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 36)))
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(8)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 44)))
dImpliedMantissa = 1 + dImpliedMantissa
' Debug.Print "Implied Mantissa: " & dImpliedMantissa
' Debug.Print StrConv(dImpliedMantissa, vbUnicode)
d = lSignOfMantissa * dImpliedMantissa * (2 ^ lBiasedExponent)
cv8ByteArrayToDouble = False
d = 0 ' 0 vallue
Sending Double Byte Characters Over RS232 Using In VB
I have a console C++ app that send a character over a Comm port without a problem, the characters for instance in hex are 0x90 also any character I assume in the unicode range, but when I try to send a character in this range using VB and the CHR() function I get a message "runtime error5 invalid procedure call, it seems if as if the CHR() function cannot convert value greater than 255,
In the help file it mentions something about DBCS systems and there ability to operate in the range of -32768 to 65535, is there a work around that anybody has doen to overcome this limitation and does anybody know how to enable DBCS on Windows 2k (if that solves the problem)
Thanks very much
Writing Double Byte Characters Into Ascii File
I need to write some text string reading from a database into ascii file. The string could be a mix of English and double byte characters like Japanese etc.
Can I write in the following way (sequential file type)
Open FileName For Append As #1
Print #1, text
or do I need to open a binary file for writing??
Handling Double Byte Characters In ASCII File
Sorry for shootting questions again on double byte character set. I'm writing an application for extracting data from SQL server and writing into ascii files. The application is written in VB and would run in multiple countries like Japan, china etc. I've no issues with countries which have all their data in English. The application will be running on the respective regional Windows Operating system of countries. When running for Japan, the double byte characters are written properly in the respective positions in the ASCII file meaning if column positions 1-10 are for name, then I can see 10 Japanese characters. ( This holds good even if the charcaters are a mix of English and Japanese). When I open this file in any Windows system with default Japanese code page, then col 1-10 would display these charcaters properly. But if I open the same file with default code page as English, then this would actually take 20 column positions if all the characters are Japanese(every charcater is split into 2 positions and the characters appear as garbage). The destiantion program reads and interprets the files based on the column positions and because of the double byte split , the destination program can not get the correct values . Moreover the destination program is running on a Unix machine and it receives feeds from multiple countries. So when it expects col 1-10 as Name, 11-20 as ID, works fine if all the characters are english, but if is a double byte , then column positions would have shifted because of the double byte split and it cannot interpret values properly. Can any one help me in handling this?
Thanks in Advance
High Speed Finding Strings, INCLUDING Double-byte Chars
I need to write a module that its function is to find strings in another string incluing double-byte characters. This is very important!!! Because I had tried the SendMessage with EM_FINDTEXT & EM_FINDTEXTEX and it runs, but it couldn't find double-byte characters in Win98 but WinNT. So I need a solution to solve this problem. Find double-byte characters both in Win98 and WinNT.Of course, I need it to find in very large text and has very high speed. Who can help me, Thank you very much!!!
Little Endian To Big Endian
I am reading a wav file to extract the raw pcm. My understanding is that the wave format stores in little endian byte order whereas the raw data should be in big endian. The file is read in as an array of 2008 bytes. Is there a quick way to pipe this array into another array reversing the byte order or alternatively forcing vb to fill the array in big endian.
I am reading in the bytes with:
Private Declare Function ReadFile Lib "kernel32" _
(ByVal hFile As Long, _
lpBuffer As Any, _
ByVal nNumberOfBytesToRead As Long, _
lpNumberOfBytesRead As Long, _
ByVal lpOverlapped As Long) As Long
part of the random cls provided by microsoft.
As a last resort what would be the most efficient for/next loop - with optimisations during compile
Little Endian To Big Endian
I am having some problems with converting some Little Endian values to Big Endian. I am trying to parse an APE tag header, but all values are 32 bit Little Endian. The version is stored as 0xD0 0x07 0x00 0x00. How would I convert this to 0x00 0x00 0x07 0xD0 (so the returned value will be 2000)?
Oh, one more thing... The above value is stored inside a 4 dimensional byte array.
PS: Sorry for posting a request, but I really don't get further.
Apologies here because it seems code is on this site, but after a few hours of searching and trying code, just can't seem to get it.
What I need to do output to a file the hex representation of signed 16 and 32 bit integers - in big-endian order.
I've tried two methods:
1) Get the hex representation (Hex function) of the integer or long, then figure out the algorithm to switch to big-endian.
2) Use API calls wsock32.ntohl, wsock32.ntohs and kernel32.RtlMoveMemory.
Problems with #1:
I can't seem to figure out how to get the result from Hex() properly to the file. For example, for the number 257, Hex returns 101. But when sticking to the file, how do I know if it should be written as 10 01 or 01 01? I know it's 01 01, but not sure how to parse, especially with larger results. In addition, this is still in little-endian order, so there's more work to do.
Problems with #2:
Crashes every time for me, probaby something I'm missing, not sure. Also, I'm not sure if the results returned will be what I need. My failed code:
Dim iNum As Integer
iNum = ntohs(257)
Dim sNum As String
Call CopyMemory(sNum, ByVal iNum, 2)
Any help is much appreciated,
Little Endian / Big Endian
Over time I've seen a few questions here about big/little endian and I just ran across this most excellent explanation that I though we could squirrel away and point to if the question comes up again. This one even has the endian expectations of numerous major applications and I've never seen that all in one place before.
Big Endian To Little Endian
I am attempting to convert both long values and integers from big endian to little endian for a project( have to save a .wav file) and am having trouble getting VB to do this.
Does anybody know how i can achieve this or have some idea of where i could look to find a solution?????
Thanks in advance
Big Endian Doubles
I am having problems converting a double (8 bytes) from intel to unix format for writing to a file. Can anyone give me any ideas what's going wrong with this code?
Private Type udtTwoLongs
Long1 As Long
Long2 As Long
Private Declare Function HostToNetLong Lib "ws2_32.dll" Alias "ntohl" (ByVal v_lng32BitLittleEndian As Long) As Long
'Converts an Intel (Host) 32 bit byte order to Unix (Net)
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
'Copy bytes of memory from one location to another
Public Function WriteDouble(ByVal dblValueToWrite As Double, Optional ByVal blnIEEE As Boolean = False)
Dim typTwoLongs As udtTwoLongs
If blnIEEE Then
'Convert to bigendian
CopyMemory typTwoLongs, dblValueToWrite, 8
typTwoLongs.Long1 = HostToNetLong(typTwoLongs.Long1)
typTwoLongs.Long2 = HostToNetLong(typTwoLongs.Long2)
CopyMemory dblValueToWrite, typTwoLongs, 8
'Write out the value
Put #m_intFileNumber, , dblValueToWrite
Little Endian Order?
trying to write a small app that manipulates a 16-bit 44.1khz wav file.
i have found out that the data in the data chunk of the wav is stored as 2's complement signed integers, in little endian format (i think this means that the two bytes are reversed, right?)
i hope to open the wav as a binary file.
to access the data, do i read in 2 bytes at a time & work out the 16bit number by reversing them & then applying two's complement?
or is there a data type that will do all this for me?
I need to convert a single data type number into 4 bytes in Big-Endian format so I can transmit the number through MSComm.
For example, how would I convert pi=3.1415 and put it in a buffer (say txBuffer()) and transmit it using MSComm.Output = txBuffer()?
Been working on this a couple days and still haven't found a resolution. Any help would be greatly appreciated.
VB Big Endian Question
I'm decoding a file that is written in Big Endian (Motorola). I've found a pretty nice technique to read in 4 bytes of data, byte swap it, and convert it to a Long Data Type.
However, I'm trying to decode a few parameters as a Single Data Type. I bring it in, byte reverse it and tried to use CSng( ) ... but that just returns the floating point integer equivalent.
Any ideas how to convert Endian with VB?
Getting A 'Little-Endian Size Of String'
Hi, this may sound like a weird question and I don't undertstand the concept of Big-Endian or Little-Endian much (guilty as charged ), but I got told that for a protocol I needed to do this:
where header the a 4-byte little-endian size of the body and body is
(the body / string )
My current code gets a 2-byte little endian size of a string and it is:
Buf1 = (Len(buf) Mod 256)
Buf2 = ((Len(buf) - Buf1) / 256)
(where buf is the string to get the length of)
Unfortunately, this isnt my code, as I have no idea how 'Mod' works.
Any feedback is appreciated
Swapping Endian ( Little ) Problem
Firstly, me and my friend Ang88 are making a program for Halo in which changes numbers ( Specificly a Reflexive into an Offset and an Offset into a Reflexive ) However, we are stumped on Switching Endian. This is for example putting in a Text Box 12345678 and then clicking a Command Button and then a label below says 78563412 - That is swapping endian ( little ) if you didn't know. We are trying to get the number to load in 2 each by using arrays and stuff and then reorganizing them. However we are having trouble with this code:
Private Sub Command1_Click()
'// Pillar of Autum Change To Offset
' If Combo Selected Option Is "A10 ( Pillar of Autum )" Then Do Formula Below
If Combo1.Text = "A10 ( Pillar of Autum )" Then
' Declare Variable
Dim blah As String
' If Field Is Blank Then Exit Sub
If Text1.Text = "" Then Exit Sub
' Make "blah" Equal To Text1.Text
blah = Text1.Text
' Declare Variable
Dim Ang88() As String * 2
' Declare Variable
Dim i As Long
' Declare Variable
Dim i2 As Long
' Set Variable Value
i = 1
' Set Variable Value
i2 = 1
' Dim Ang88 Again
ReDim Ang88(1 To Len(Text1.Text))
For i2 = 1 To Len(Text1.Text)
Ang88(i) = blah
For i = Len(Text1.Text) To 1 Step -1
' Within Text Answer Field Put The Value Which Is Ang88
Text2.Text = Ang88(i)
' End The If Statement
' Set Focus To Answer Field
Within this area of code:
For i2 = 1 To Len(Text1.Text)
Ang88(i) = blah
we are having trouble. How would we load that info into a variable?
Thanks to anyone who replies
Convert Long To Big Endian
I want to convert a long integer to its four character string big endian representation .
Any help on this ?
Saving/Loading As Big-Endian
I am needing to load and save to a specific file type that was created using Motorola (Big-Endian) byte order.
It contains dynamic length strings which is where the difficulty arises.
The other thing i'm seeing is the strings length bytes are only 16 bit. So instead of each string being preceeded by a 2 byte value indicating the length of the string, its preceeded by 1 byte.
So when VB tries to Get the data from the file into the UDT...it ends up thinking the first character of the string is part of the length and allocates way too much for the string.
So...im stumped. Any thoughts?
Make A 64 Byte Or 128 Byte Number Storage Unit?
is it even possible to create a numeric varible to hold a number 64 BYTES long?
the reason im asking is because i need to preform logarithms on gigiantic numbers.
also if any one knows how to do a logarithm in VB (NOT math.Log, the actual formula, aka Taylors series) i could use this as well!!
Convert Any Object Into Byte Array. (or At Least Stdpicture To Byte())
Hello. I need to convert any object into a byte array. If that's not possible, I need to at least be able to convert a stdpicture (I think thats the kind of image you get when you get a picture from the clipboard, printscrn...) to a byte array.
I really need to be able to do this to send pictures over directplay.
Please help me out. Thanks.
Didn't want to bump up the topic because the problem was resolved. Thanks for your help onerr0r!!
Little Endian, MIDI File Creation
I've never done anything with MIDI programming. I have played MIDI files, and have some grasp of them only from this perspective. I was hoping to produce at a minimum a capability to translate musical notes based on standard notation into MIDI data, and hopefully, play back note sequences in MIDI. I've been referred to MIDI standards, but they seem to spend some time discussing manipulation of bytes in terms of big and little endian representation. I am fairly lost. Is there any straightforward, well documented code out there that demonstrates how to transform, say, a middle C note into a MIDI output with a specific duration? The first challenge is establishing how to take a note name and turn it into MIDI data. The next is how to produce sequences of notes with whatever separators are necessary. The third, and, I hope, final one, is identifying how to package the file to tell the MIDI device to start playing, to play the specific notes indicated, and then to stop. (A fourth might be how to save all this so any MIDI device can open the file and play it back.) I'm just interested in one instrument, single track output right now. I know this is quite a bit to request, so please keep the following in mind. If you can help, wonderful. If not, please don't push yourself just to answer these questions. I know you've got better things to do. The references I've seen don't appear to include any code examples.
Thanks for any assistance.
Read Big-Endian Files From LabView In VB6
I'm trying to read in VB6 the files I've generated with LabView. I've read that the format of LabView files is Big-Endian, while VB6 reads binary files in little-endian.
There is an example file in:
It's a wave register. Data is voltage in a [-10,+10]range.
I hope someone can help me, or at least, give me some "clues", I'm getting crazy with it...
Thanks in advance!
String Of Numbers Decoder - Byte By Byte
I did a few searches and came out to no avail. I can make this code work, but it's absolutely too slow. Let me write out the situation:
I have an encryption key, 255 characters represented, each byte respectively, for an ASCII numeric system. Right now I have it as a string, ex:
"32,56,71,99,255,61" continued for 255 entries.
What I want to do is, put this into a byte array so like:
Dim ByteArray() as Byte
ByteArray = Split("32,56,71,99,255,61", ",") 'and so forth, 255 numbers
Problem is, the split requires the ByteArray to be a string. So what can I do about this? I tried making two arrays
Dim StringArray() as String
Dim ByteArray as byte
Dim i as integer
StringArray = Split("32,56,71,99,255,61", ",") 'and so forth, 255 numbers
for i = 0 to 255
bytearray(i) = stringarray(i)
The above doesn't work either. I'm obviously missing some key conversion function. Anyways, once I get this all said and done, I want it to take this array and go like
dim Buffer() as byte 'Data that needs to be decoded
dim ByteArray() as byte 'Decoder key values
for i = lbound(buffer) to ubound(buffer)
buffer(i) = bytearray(buffer(i))
text1.text = asc(buffer(i))
Simple as that, decode the values... This should execute really quick, even with a ~1500byte+ sized file correct?
Anyways, thanks for all your help and hopefully I can get this figured out. ^_^
My biggest concern is speed of the whole process.. I right now have problems executing the above without taking a good 15-30 seconds per file. I believe it has to do with me not properly converting..
cdec()? cint()? cbyte hehe?
Error In &"double = Double - Double&" Statement
I am trying to compute the differnece between two dwords in visual basic and
keep getting the wrong value being computed. I have the following structure
Public Type HighLowQuote
TradeDate As String
OpenPrice As Double
HighPrice As Double
LowPrice As Double
ClosePrice As Double
Volume As Long
AdjClosePrice As Double
AmtChange As Double
I create an instance of this type as 'q'. I then do the following:
q.highprice = variant
q.lowprice = variant
at this point the locals variable window shows the values as:
q.highprice = 4.1
q.lowprice = 4
I then fall through the following code:
q.AmtChange = q.highprice - q.lowprice
q.amtchange is then valued at 9.99999999999996E-02 in the locals window when
I believe it should be valued at .1.
Why is the value not being set to .1? Is there a change I can make to get
this calculation to work how I expect or is there some other way to perform
these calculations to get the results I am after?
Any help would be appreciated. Thanks in advance.
VB6: How To Read Data From Binary File In IEEE Floating Point, Little-Endian Format?
I have a proprietary binary file here that contains a variable called 'Hydroxyl #', seven sample titles (2, 5, 9, 12, 20, 23, 31 - these titles could just as easily be text, so they are probably stored as strings), and the associated float values for the variable (44.94, 46.17, 51.93, 54.08, 61.62, 63.75, 84.77). I have attached the zipped data file in 'Polyvl.zip'.
Below, I have also pasted a Matlab script that a long-since departed member of our company wrote to read the file. The script uses the 'fopen' command with the 'ieee-le' option (IEEE Float-Point, Little-Endian, bits not explicity specified).
My question is, how do I properly read (and also, display) this data properly in Visual Basic 6? I am currently using the 'Open ... For Binary Access Read ...' statement and the 'Input' statement to read the data into a Variant type variable. I am able to grab some of the data (Hydroxl #), but the rest looks like garbage.
Contact me at DSanborn3@hotmail, or DSanborn3 (at AIM, MSN, Yahoo) with additional questions or comments. TIA!
//-----Begin Matlab Script (read_da.m)---------------
% READ_DA -- read NIR NSAS data files.
% Will not work for full Vis/NIR range.
% Works for spectra transferred from pc to rs/6000 via binary ftp.
% See read_fda for reading full Vis/NIR range.
[fn,pt]=uigetfile('*.da','Select NSAS *.da file');
fn = fullfile(pt,fn);
% loop for reading sample names
spl_name(nspec,1:30)=[setstr(k(5:14))' sprintf(' %2g:%2g:%2g %2g-%2g-%4g',hr,mi,se,mo,da,yr)];
//-----End Matlab Script (read_da.m)-----------------
Swap Red And Blue
This is what I'm using to swap the red and blue channels from a RGB colour value:
LeftByte = Col And &HFF0000
MiddleByte = Col And &HFF00
RightByte = Col And &HFF
Col = ((RightByte * 256) Or MiddleByte) * 256 Or LeftByte
and I'd like to know if someone can make this more simplified and, specially, faster for when you have to do this for all the pixels in an image.
How Do I Swap For Sorting
Hello Can Anyone Help
Private Sub Swap(ByRef A As String, ByRef B As String)
Dim T As String
T = A
A = B
B = T
Private Sub cmdSort_Click()
Open "swapsort.Dat" for Input as #1
While Not EOF(1)
c% = c% + 1
ReDim a$(1 To c%)
ReDim b$(1 To c%)
Input #1, a$(c%), b$(c%)
Open "swapsort.Dat" for Output as #1
For i% = 1 To c%
For j% = i% + 1 To c%
If a$(i%) > a$(j%) Then
What to write here For SWAP .............
print #1, A$(i%), b$(i%)
I have a large VB project that uses a 3rd party control that I need to replace with another 3rd party control. For example, I have to replace all my current command buttons with a new set of buttons. Is there any automated or speddier way to do this rather than replacing each instance by hand?