Display KB Not Bytes 391 KB (401303 Bytes)
Aug 2, 2009Probably missing something silly here, Her eis what my display looks like Sending image...(401303) I would prefer it displays as Sending image...(391 kb)
[Code]...
Probably missing something silly here, Her eis what my display looks like Sending image...(401303) I would prefer it displays as Sending image...(391 kb)
[Code]...
I want it to do is that you input a string, then you select an algorithm (Theres only going to be one RijnDael) then you input a key, then the Initialization Vector comes from "txtIV.text" then you select the key bytes and the block bytes from the numeric up/down, then you either encrypt or decrypt.
View 1 RepliesOk i am having some issues designing a base-class to handle generics.Caveat is i need to restrict the type put in as a Numeric type, specifically Int16, Int32, or Int64 (Short or Long).I know you can do Of T as {Structure} but i dont want to select the key bytes and the block bytes from the numeric up/down.
View 2 RepliesI keep getting a ProtocolViolationException "Bytes to be written to the stream exceed the Content-Length bytes size specified." on the following code.I've tried setting Content-Length numerous ways with no success.
Dim url = "https://domain.com"
Dim req As WebRequest = WebRequest.Create(url)
req.Method = "POST"
req.ContentType = "application/xml"
[Code]...
What exactly does this line do?
i = stream.Read(bytes, 0, bytes.Length)
Does it read the entire message string sent by the client? I have a line to write to the stream later in the code and that does not seem to be sending anything back to the client, although the code around is excuting.
i = stream.Read(bytes, 0, bytes.Length)
While (i <> 0)
Try
' Translate data bytes to a ASCII string.
[code].....
I created a text file contains 4 bytes of data
AABBCCDD
I just want to read the first 2 bytes (AABB) to execute it with my program.
Then I'll need to read the last 2 bytes (CCDD) for another computer routines
im trying to format my results from some WMI quires but im not having much luck.
i want to display my available memory as Mb's not Bytes. in the past ve done the following
vb
result = (queryObj("TotalPhysicalMemory")) / 1024
usually that works but its giving me a retarded result, its giving me 3581.98828125 as the result, but i do the same way with my video card memory and it displays it as 512 like it should. ive tried every way i know of formatting and decimals but non of it is working.
im dsplaying my result in a text box and ive also tried formatting it thier with no such luck
Me.txtmemorycap.Text = text
I'm working on a project involving reading RFID tags, I've written the code and it reads the tags ok by using the recieved data handler and displaying the result in a listbox, the only problem is that the data displayed has a couple of unreadable characters at the start (I'm using ReadLine() command.)If I read the buffer byte by byte the data is all readable.How can I read and display the whole 16 Bytes in one go??
View 3 RepliesI am not sure how to explain but will try through example. I need to be able to add bits to a byte see below.
I have a total of four bytes (256mb). I need to be able to add the bytes to get 256?
Example: Byte1 = 0 Byte2 = 0 byte3 = 108 byte4 = 1 I need this to equal 217 (11011001) 108 (1101100) + 1(1) = 217(11011001)
I'm writing a VB.net application (but you can answer in C# if you want, no problem) that uses a 3rd party .NET library. In particular, one method in this library takes an IO.Stream as input (among other things) and writes the results of its processing to said stream. My problem is that the method CLOSES the stream after writing to it, so I can't read back the data that it wrote in it!To be more specific: it works, of course, if the stream is a FIeStream , since it writes the data on disk, but what if I want to read the data directly to memory? I tried using a MemoryStream, but as I said, when the method returns the stream is already closed, and I can't read back anything from it.
Imports System.IO
Public Class CloseHijackedMemoryStream
Inherits MemoryStream
[code]...
I am using this code, I got it to work fine with any C# assembly that allows it to be ran from memory. Is there anyway I could get it to work with VB.net?
private static void RunFromMemory()
{
try
{
[code]...
The error I receive is "Parameter count mismatch"
i have seen many posts resolving issues with converting bytes to KB, MB and GB...how would i convert GB,MB and KB to bytes?
View 11 RepliesI am trying to compare two files and I do not know why, the filed downloaded to be compared, is always only 44.898 bytes, despite of being bigger... what am I doing wrong, I post the
[Code]...
I have a simple problem (I think). I would like to get the CRC of this array of bytes
0x0 0x7E or 0 7E or 0
Anyway the one calculator I use gives me: 78F0 or 78 F0 (Hex). Anyway, I think its CRC16 but im not sure. So if anyway can show me some code to give me a CRC calculation that matches (78 F0 or 78F0), that would be great, Im not sure if you have to include 7E or not
My app displays the bytes downloaded in a label using:
Private Sub MyDownloader_DownloadedByteCountChanged(ByVal ByteCount As Integer) Handles MyDownloader.DownloadedByteCountChanged
lblDownloaded.Text = ByteCount.ToString()
End Sub
But I thought it would be 'nicer' if it display the amount as kb/mb/gb, etc.
This is how i convert Bytes to KB etc.. vb.net
[Code]...
I have a single that might have a decimal place but might not. I have to put the digit before the decimal into the first 4 bytes and the digit after in the next 4 bytes.
So 1.1 would be 01-00-00-00-01-00-00-00
or 2.1 would be 02-00-00-00-01-00-00-00
or 1 would be 01-00-00-00-00-00-00-00
The digit before the decimal point is stored like an integer in bytes the same with the digit after the point. So 1.1 gets split into 1 and 1 and then stored as 2 DWORDS: 01000000 and 01000000
I have a byte array and I need to get 4 bytes from it at a certain location(16) but I don't want to convert it to a integer or anything just keep it as 4 bytes to store in a variable.
View 1 RepliesWhat is the best equivalent of SequenceEqual in VB. NET 2.0? I am trying to compare 2 byte arrays quickly and cleanly
View 1 RepliesI been given an applet for example [code]what should i put for the 8 bytes method portion? [code]but I think it might be wrong coz I didnt get any reponse from the applet.
View 1 RepliesI have a problem that i cant solve i am trying to buffer 28 bytes from the com port into the array actual_packet_VPS1(30). It works with the counter set to 0 - 15 but doesnt work when we increase the counter size to 0 -28.
Private Sub MSComm5_OnComm(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MSComm5.OnComm
Dim buffer As Object
[Code].....
In web service I have function that return bytes array. Now, I call it from VbScript and I need to catch result of this function. How I can catch result of this function in value that is gone be like a value that function return (bytes array)?
View 1 RepliesIs it possible to change few bytes in a file to make unreadable or is it necessary to change each single byte?
View 1 RepliesI'm using Visual Basic .NET to work with a USB HID device.Most of the time, I can receive data from it perfectly... but one out of every thousand transfers or so, my code will think it has received data when it actually hasn't.The device writes to an array of bytes. I wanted to check to see if the received packet is empty, by doing something like this:
If myDevice.dataPacket(1) <> Nothing then
myDevice.rxDataReady = False
[code].....
How can i compare two arrays like :
Dim Ar1,Ar2 as array
Ar1 = My.Computer.FileSystem.ReadAllBytes("C:Try.mp3")
Ar2 = My.Computer.FileSystem.ReadAllBytes("C:Try1.mp3")
how can i compare that two?
I'm trying to convert standard bytes like so:
00DEAD00BEEF0000
and convert it to base64.
I want it to go from bytes -> Base64.
Not
String -> Base64.
I have been looking for a way to convert bytes down into another unit and append the unit format to the end and return it. I have found a few posts about it but I didn't perticularly want to write that much code that they listed, so I designed "my own" (I'm sure I'm not the only one who has done this method).Since I am pretty new at all this, I was wondering if anyone could let me know if there are any problems with how it would process the information and perhaps make it faster.[code]
View 29 RepliesI'm using this code to count up bytes in list box 5. It works but when the value of bytes is 0 i get this {Width 100, height = 200,) I think the problem is the ToString So does anyone know how to count numbers in the list box?
vb
Dim total As Integer
Dim i As Integer
For i = 0 To ListBox5.Items.Count - 1
[Code].....
I'm trying to edit the bytes in a file. Using this code:
Dim stream As Stream = File.Open("file.exe", FileMode.Open)
stream.Write(File.ReadAllBytes("srcfl.exe"), "0446335", "srcfl.exe".Length)
I was looking for a way to enumerate String types in (vb).NET, but .NET enums only accept numeric type values.
The first alternative I came across was to create a dictionary of my enum values and the string I want to return. This worked, but was hard to maintain because if you changed the enum you would have to remember to also change the dictionary.
The second alternative was to set field attributes on each enum member, and retrieve it using reflection. Surely enough this worked aswell and also solved the maintenance problem, but it uses reflection and I've always read that using reflection should be a last resort thing.
So I started thinking and I came up with this: every ASCII character can be represented as a hexadecimal value, and you can assign hexadecimal values to enum members. You could get rid of the attributes, assign the hexadecimal values to the enum members. Then, when you need the text value, convert the value to a byte array and use System.Text.Encodings.ASCII.GetString(enumMemberBytes) to get the string value.
Now speaking out of experience, anything I come up with is usually either flawed or just plain wrong. Is there any reason not to do it like that?
As pointed out by David W, enum member values are limited in length, depending on the underlying type (integer by default). So yes, I believe my method works but you are limited to characters in the ASCII table, with a maximum length of 4 or 8 characters using integers or longs respectively.