|
I guess another posible method is to take the data, and load the raw bits as 1's or 0's into a text box, change them, convert them to characters, and save them to a .bin file.
|
|
|
|
|
No, not really. Or rather, calling Winshell or some similar low-level utility is not, I regret to say, my area of expertise. People who know this sort of thing tend to look upon themselves as "genuine" computer experts, whereas I see them as people who build welding torches that the rest of us use to build skyscrapers. At any rate, before we get too far into rant territory, there's more than one way to skin a cat. The way you mentioned is probably possible, but unnecessary, and I can't help with it - instead you could use the prebuilt VB classes that are the target of the aforementioned gearhead scorn.
As for the textbox method, God forbid. Converting a bit to a character such as a 1 or 0 would be unnecessary, as would putting them in a User Interface element like a textbox - never do something unnecessary. Besides, saving the "1" character will not save a binary 1 - it will save an 8-bit character from the basic 128- or 256-member character set. This will represent a "1" as far as, for example, notepad is concerned, but is not the same as a logical 1.
Use VB's help to look up the classes we've already discussed - it's a valuable asset for examples, general concepts, etc.
Steve
|
|
|
|
|
I still don't understand. I'm sorry, I'm 13 and I'm tryign to understand the most simple programming language available.
|
|
|
|
|
Oohhhhhh, that explains it. I remember being that age and trying to program. Your brain isn't set enough to really get the concepts yet, unless you're very unusual. I was always writing programs that didn't do anything. Look at my last post near the bottom of the page; as for the rest, focus on exactly what you're doing - don't get distracted, and always remember to use the absolute simplest method possible to solve a problem. General syntax for VB can be found on msdn.microsoft.com, but here's some:
Dim a as new object (arguments)
a: is the name of the object
new: this is a specialized function that creates a new instance of an object. An object is like a blueprint, an instance of the object is like a building built from that blueprint. Think of all those identical suburban houses as instances of a House object.
object: can be any object - integer, textbox, filestream, bitarray, whatever. Not everything can be declared as "New."
Arguments are other objects that the object needs to generate an Instance. For example, the BitArray needs to get its bits from somewhere. Therefore, you tell it "use this array of bytes to make an array of bits" by passing in an argument that is an array of bytes.
dim b as byte means make one byte
dim b() as byte means make an array of bytes
dim b(10) as byte means make an array of 11 bytes (0 counts as a number).
This is only a beginning. You've got a long way ahead of you; I'd take a month or so to get really familiar with the objects in question. Use the help files, get to know the buzzwords that have definite, set meanings. Don't give up. If you learn to program at your young age, it'll be in your bones like it never can be if you only learn in University.
|
|
|
|
|
System.Object.New()
System.Collections.BitArray.New()
comes back as a declaration problem, wherever I put them...
|
|
|
|
|
I probably look like the biggest dumbass on the planet.
How to I make a bitarray, how do I name it, and how do I use "new(byte" and make it get somthing from a text box (I'm just testing it out before I mess around with files)
|
|
|
|
|
Dim fs As new IO.FileStream("[Path Here]", IO.FileMode.Open)
Dim b(fs.Length - 1) As Byte
fs.Read(b, 0, fs.Length - 1)
Dim ba As New BitArray(b)
The io.filestream is a fairly abstract concept. A "Stream" in VB is a one-way conduit between object X and the program - a filestream can be used for input or output, depending on the argument supplied. In this case, you're only reading, so we specify IO.FileMode.Open because we want to read from the file.
From here, we
1. create an array of bytes - dim b(size) as byte
2. fill that array from the file (fs.read)
3. use the array now containing the file to fill the bitarray.
You couldn't do this from a textbox because a textbox contains characters, not bits or bytes.
I suggest reading up on the concepts behind this for a little while before continuing - these are fairly advanced concepts if one is not familiar with them, and what you are doing will take considerably more code than the four lines supplied here.
|
|
|
|
|
How do I replace [path here] with it reading from a path from a textbox?
|
|
|
|
|
|
Excellent! One third the way through the proramming!
Now we just need to:
Make it consider the bits in pairs, and change them
Keep it from going over the same bits twice
Save the bits to a file.
The problem I see it this, when I open a binary file in notepad, I see characters. VB is working with the binary, and when it saves, I'm afraid if I open the file up in notepad, ill see "10101001111001" instead of characters.
Prof. Haahr's site will see the binary, and if VB saves it as 10100101, Haahr's site will see: 1111111100000000111111110000000000000000111111110000000011111111, so I want it to save 10100101 (assuming it equals "a") as "a".
You see, heres my problem. I don't trust a computer to do it's job. I wanna make sure that it will do exactly what I expect it to. I don't know if that makes me a bad program!
|
|
|
|
|
How do I make it condsider the bits in pairs, and do this to each one?
IF bit0 = bit1 then (whatever deletes both bits) ELSEIF (toss second bit)
GO ON
REPEAT IF
modified on Monday, February 18, 2008 4:22 PM
|
|
|
|
|
Steve gave you the right solution for getting your data into an array.
To work with bits though you need to learn what the AND, OR, XOR, <<, >> commands mean because computers don't know how to deal with anything smaller than a byte directly. If you google bitwise there are lots of good tutorials that will explain each of them well. The AND command will allow you to isolate the bits you want to test, then you can easily set up a condition statement to to test the number without irrelevent bits infearing. For instance you can isolate the first 2 bits like this
result = yourbyte AND mask
if mask has a binary value like this 11000000 then all the irrelevent bits will become zero and allow you to test for only 2 different numbers.
hope this helps,
Mike
|
|
|
|
|
I have created an application in which there r several forms open and when i click logout button then all the open forms should get closed and login page should get open.so, how do i close all open forms.
coolsatty
|
|
|
|
|
Application.OpenForms Gets a collection of opened forms owned by the application.
Eslam Afifi
|
|
|
|
|
but how do i close it.
coolsatty
|
|
|
|
|
iterate through them and close them
For Each form As Form In Application.OpenForms
form.Close() ' close the form
form.Dispose() ' to clean up resources
Next
Eslam Afifi
|
|
|
|
|
application.openforms is not there in vb.net.
coolsatty
|
|
|
|
|
Application.OpenForms is new to the .Net Framework 2.0 (VB 2005)
Eslam Afifi
|
|
|
|
|
then how to do in VB 2003.
coolsatty
|
|
|
|
|
Sorry, I can't help It's been a long time since I used the .Net 1.1 and I currently don't have VS 2003 installed.
Eslam Afifi
|
|
|
|
|
Dim myarray() As Integer
Dim i As Integer
For i = 0 To 15
myarray(i) = 2
Next
In the 4th line I gets an error message as under:
Variable 'myarray' is used before it has been assigned a value. A null reference exception could result at runtime.
Please correct the code ....
|
|
|
|
|
You have declared a reference for an array, but not created the array itself.
The easiest way to create the array is to specify the size (i.e. the highest index to use) when you declare the reference:
Dim myarray(15) As Integer
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
The array you are using hasn't been initialised, try
Dim myArray(15) as Integer
I find arrays cumbersome in .Net compaired to VB6 and so I tend to use ArrayLists or other collection methods instead.
An optimist's glass is half full.
A pessimist's glass is half empty.
An engineer goes and gets the right size glass.
|
|
|
|
|
How can make a 30 Days evalation copy of a windows based application which is developed in VB .Net 2003.
The thing is, after finishing 30 days of evaluation period,even though if the client changes his system's date the application should not work.
If anybody have any information,please help.
Joby Mathew
|
|
|
|
|
If somebody is prepared to change the date on their PC to run your program past the 30 day trial, then they aren't prepared to pay for it anyway.
They'll also happily run it in a VM and reinstall every 30 days...
|
|
|
|