|
|
The length value that i get back is bigger than the scope for that element.
|
|
|
|
|
This works fine:
string[] test = new string[] {
"Hello World!",
"This is a great day"
};
MessageBox.Show(test[1].Substring(test[1].Length - 3, 3));
|
|
|
|
|
LCI wrote: this blows up
string test = "THIS IS A GREAT DAY";
string day = test.Substring(test.IndexOf("DAY"), 3);
That works just fine here.
|
|
|
|
|
That works fine provided that the string is constant. What i am attempting to accomplish is to get the last 3 chars no matter what.
So i do something like
end = strArray[10].Length;
string strText = strArray[10].SubString((end-3), 3);
The end value seems to be bigger than the scope for strArray[10]
|
|
|
|
|
LCI wrote: What i am attempting to accomplish is to get the last 3 chars no matter what.
What if it is shorter then 3?
Remember that in string indexing starts from zero.
|
|
|
|
|
Remember that character indexes are 0 based, where the length counting starts at 1. To give an example, the string "day" has a length of 3 right? But the last character index is 2, not 3! The reason is that character index is 0, so [0] is d, [1] is a, [2] is y.
if (strArray[10].Length >= 3)
{
int lastCharacterIndex = strArray.Length - 1;
string strText = strArray[10].SubString(lastCharacterIndex - 3, 3);
}
|
|
|
|
|
|
It is 85501rrA backwards.
led mike
|
|
|
|
|
|
|
"If Google can't find it, it doesn't exist"
|
|
|
|
|
That's what I thought
|
|
|
|
|
Maybe so, but Google knows about "Arr 10558" ...
|
|
|
|
|
the screen name of a Pirate born on 10/5/58
|
|
|
|
|
I have a printer that I need to send raw data to and have it print. This printer uses special syntax to print barcodes and other items onto the paper. The printer has three ways to send data to the printer. If you were going to program something to send data to the printer, what would you use?
1. USB - Seems to be the best option but it appears that many people have problems sending data to USB ports to devices.
2. Parallel Port - Many new computers do not have serial ports so I dont think this would be the best option.
3. CAT5 - It has a ethernet jack which seems like it would be a great option but could cause problems if this printer is moved around alot trying to configure the port for it to print to.
I know that my thoughts basically say use #! (USB) but I thought I would just get other people's options.
|
|
|
|
|
I would definetely use USB, it's a lot faster. You might even consider Firewire.
Brad Wick wrote: it appears that many people have problems sending data to USB ports to devices.
I'm not sure what you mean. I've never heard of people having problems with USB.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
It is true that a lot of programmers have problems with the security surroudding the use of USB. I experienced that especially with lab equipement and some "special" printers. This happens especially when multiple users use the same computer. Directly connected printers is also a thing of the past for corporate environements, and the IP address problem can be addressed with the use of DNS server and your DHCP server.
The answer is more in who is your target market:
For corporate environments go with Ethernet.
For home and very small SBS, go with USB. And if you use USB test,test,test,test.......
|
|
|
|
|
It will be home or a company with only one computer so I think it would be best to stick with the USB. Now the next problem is that I can not find any good docs on sending data to a USB port that I can understand. Like I said before it appears many people have problems with this type of application. The application I need is so simple also...
Have a large scrolling text box that you type in what you want sent to the USB port and a submit button. Once you click submit it would send the exact data that is in the textbox to the port.
|
|
|
|
|
Brad Wick wrote: 2. Parallel Port - Many new computers do not have serial ports so I dont think this would be the best option.
You're right to avoid this. Most mobos I've looked at that dropped the last rs232 port also dropped the parallel port as well. More than that, while I've seen a few high end DIY mobos that had an optional rs232 bracket to put a port in the on the back where the expansion slots are, I've not seen any mobos that do the same with the parallel port. Probably because a 25pin header takes a lot more space than a 9pin one. (The latter is the size of a USB/Firewire header on the mobo).
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
What is the best way to write an array list to a txt file so that reading from it would be straightforward.
I am using StreamWriter class and i have an array list(Alist) that contains say
1
2
3
4
5
6
Can i just do a Write(AList) or should i be doing a WriteLine because when i read the file again i mya have to to do a realine to get it all line by line to put back into an Array list.
What is the best way to do this?
|
|
|
|
|
Use the writeline in the streamwriter.
Ben
|
|
|
|
|
Is there some cool class or way of writing the array list in one or would i have to parse through the entire array and writeline one by one?
Same question for reading from the file to put into the array list?
|
|
|
|
|
I guess if you really want the writing and reading to be quick you should think about serializing the object and saving that xml. Then you can read the xml and de-serialize it back into your object. Otherwise you are stuck with writeline and readline.
Ben
|
|
|
|
|
I kinda like that idea.
What exactly do you mean by serialize?
Speed is kind an issue for me.
|
|
|
|