hai,
At present I'm facing a strange problem. We are converting a project from
VB to .NET
One record contains Chr(0). Let the record be of length 1800. In the 50th
byte of a record a chr(0) is there.
While I use VB to read it's giving all 1800 bytes. But when I converted my
VB to VB.NET, after the 49th byte all the bytes are truncating. I have to
solve this issue to proceed further. I hope the experts around here can solve
my problem.
I'm using the random file and using a structure of length 1800 bytes.
Following is the code I use
Public Structure StudentRCDetails
<VBFixedString(1800)> Dim lsData As String
End Structure
Dim lStructDetails As StudentRCDetails
FileOpen(liKeyFileNum, lsFilePath, OpenMode.Binary, , OpenShare.Shared, 1800)
FileGet(liKeyFileNum, lStructDetails , Integer.Parse(lsStudentID))
FileClose(liKeyFileNum)
I'm getting only a part of a string. ie. till the Chr(0). After, all the
datas are discarded.
I tried with opening in Random mode also. The result is same for both the
cases.
Please help me in this issue. It's urgent
regards,
Venkatarajan 11 1755
Venkatarajan <Ve**********@discussions.microsoft.com> wrote: At present I'm facing a strange problem. We are converting a project from VB to .NET One record contains Chr(0). Let the record be of length 1800. In the 50th byte of a record a chr(0) is there. While I use VB to read it's giving all 1800 bytes. But when I converted my VB to VB.NET, after the 49th byte all the bytes are truncating. I have to solve this issue to proceed further. I hope the experts around here can solve my problem.
Are you *absolutely sure* that it's actually being truncated? How are
you examining the string? If it's in the debugger, try printing out the
string - you may well find that the rest of the data is there, it's
just not being shown in the debugger.
(I would be more confident about this if you were using standard .NET
IO classes - I'm not familiar with the VB functions you're using.)
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hai Jon,
I tried to print it out in the debugger?. Let assume the string be
"Venkat" & Chr(0) & "rajan".
When I tried to print it in the debugger it shows as
"Venkat
When try to extract character by character, it shows me a error.
Not even the terminating quotes.
Help me out
Regards,
Venkatarajan
"Jon Skeet [C# MVP]" wrote: Venkatarajan <Ve**********@discussions.microsoft.com> wrote: At present I'm facing a strange problem. We are converting a project from VB to .NET One record contains Chr(0). Let the record be of length 1800. In the 50th byte of a record a chr(0) is there. While I use VB to read it's giving all 1800 bytes. But when I converted my VB to VB.NET, after the 49th byte all the bytes are truncating. I have to solve this issue to proceed further. I hope the experts around here can solve my problem.
Are you *absolutely sure* that it's actually being truncated? How are you examining the string? If it's in the debugger, try printing out the string - you may well find that the rest of the data is there, it's just not being shown in the debugger.
(I would be more confident about this if you were using standard .NET IO classes - I'm not familiar with the VB functions you're using.)
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Venki <Ve***@discussions.microsoft.com> wrote: I tried to print it out in the debugger?. Let assume the string be "Venkat" & Chr(0) & "rajan". When I tried to print it in the debugger it shows as "Venkat When try to extract character by character, it shows me a error. Not even the terminating quotes.
Help me out
Don't print it out in the debugger - print it out in a console window.
Basically, don't trust the debugger when it comes to strings, until you
know exactly how it handles them.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
I tried it in Command Window. It gives the same result. Help me to solve this
issue.
Regards,
Venkatarajan
"Jon Skeet [C# MVP]" wrote: Venki <Ve***@discussions.microsoft.com> wrote: I tried to print it out in the debugger?. Let assume the string be "Venkat" & Chr(0) & "rajan". When I tried to print it in the debugger it shows as "Venkat When try to extract character by character, it shows me a error. Not even the terminating quotes.
Help me out
Don't print it out in the debugger - print it out in a console window. Basically, don't trust the debugger when it comes to strings, until you know exactly how it handles them.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Venki <Ve***@discussions.microsoft.com> wrote: I tried it in Command Window. It gives the same result. Help me to solve this issue.
Don't try it in the command window, try it in the console - using
Console.WriteLine - as I suggested before.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
hai jon,
It's working fine when I tried with Console Application. But when did the
same with Web Services or Windows application the string is getting
truncated. Please help me in this issue.
Dim str1 As String
str1 = "Venkat" & Chr(0) & "Rajan"
Console.WriteLine(str1)
Console.ReadLine()
It gave Venkat Rajan in Console Application.
Dim str1 As String
str1 = "Venkat" & Chr(0) & "Rajan"
msgbox(str1)
When I used a windows Application , it showed me only Venkat.
Thanks in Advance.
Regards,
Venkatarajan
"Jon Skeet [C# MVP]" wrote: Venki <Ve***@discussions.microsoft.com> wrote: I tried it in Command Window. It gives the same result. Help me to solve this issue.
Don't try it in the command window, try it in the console - using Console.WriteLine - as I suggested before.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Venki <Ve***@discussions.microsoft.com> wrote: It's working fine when I tried with Console Application. But when did the same with Web Services or Windows application the string is getting truncated. Please help me in this issue. Dim str1 As String str1 = "Venkat" & Chr(0) & "Rajan" Console.WriteLine(str1) Console.ReadLine() It gave Venkat Rajan in Console Application.
Dim str1 As String str1 = "Venkat" & Chr(0) & "Rajan" msgbox(str1) When I used a windows Application , it showed me only Venkat. Thanks in Advance.
That's just because message box will truncate strings. The string
itself is fine.
If you want to get rid of the nul characters, use String.Replace and
replace them with whatever you want (eg space).
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hai Jon,
See my first post. I'm getting the Structure of length 1800 bytes. When I
tried to read it from the file, the character what I'm getting is terminated
when it reaches the null string. I have solve this issue.
Thanks in advance
Regards,
Venkatarajan
"Jon Skeet [C# MVP]" wrote: Venki <Ve***@discussions.microsoft.com> wrote: It's working fine when I tried with Console Application. But when did the same with Web Services or Windows application the string is getting truncated. Please help me in this issue. Dim str1 As String str1 = "Venkat" & Chr(0) & "Rajan" Console.WriteLine(str1) Console.ReadLine() It gave Venkat Rajan in Console Application.
Dim str1 As String str1 = "Venkat" & Chr(0) & "Rajan" msgbox(str1) When I used a windows Application , it showed me only Venkat. Thanks in Advance.
That's just because message box will truncate strings. The string itself is fine.
If you want to get rid of the nul characters, use String.Replace and replace them with whatever you want (eg space).
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Venki <Ve***@discussions.microsoft.com> wrote: See my first post. I'm getting the Structure of length 1800 bytes. When I tried to read it from the file, the character what I'm getting is terminated when it reaches the null string. I have solve this issue.
I'm still not convinced it *is* actually being terminated - have you
tried printing out the string *to the console* (not the debugger, not
the command window, not a web page, not a message box) after reading
it?
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hai Jon,
As you said I tried to print it in the console. It's displaying
correctly. But when tried to do some calculations based on the string, I'm
unable to get the whole part of the string.
Thanks in advance
regards,
Venkatarajan
"Jon Skeet [C# MVP]" wrote: Venki <Ve***@discussions.microsoft.com> wrote: See my first post. I'm getting the Structure of length 1800 bytes. When I tried to read it from the file, the character what I'm getting is terminated when it reaches the null string. I have solve this issue.
I'm still not convinced it *is* actually being terminated - have you tried printing out the string *to the console* (not the debugger, not the command window, not a web page, not a message box) after reading it?
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Venki <Ve***@discussions.microsoft.com> wrote: As you said I tried to print it in the console. It's displaying correctly. But when tried to do some calculations based on the string, I'm unable to get the whole part of the string.
You should be able to, just using the standard .NET string access
methods. What's failing for you?
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: David Gray |
last post by:
Greetings all,
I'm working on a program that allows a user to enter notes in a
multiline textbox. I would like to be able to read the contents of
the textbox (as records - one per line) and...
|
by: Dietrich Epp |
last post by:
Are there any good modules for reading a bitstream? Specifically, I
have a string and I want to be able to get the next N bits as an
integer. Right now I'm using struct.unpack and bit operations,...
|
by: Tim::.. |
last post by:
Can someone please tell my why I get the following problem when I type the
following piece of code!
How do I get around this???
The idea is that when a user clicks a button on a form it causes...
|
by: Bruce Wiebe |
last post by:
hi all
im having a problem accessing a text file on my hard disk after ive
created it and added some text to it it would appear that the file is
still locked.
What happens is this i have...
|
by: jeff M via .NET 247 |
last post by:
I'm still having problems reading EBCDIC files. Currently itlooks like the lower range (0 to 127) is working. I have triedthe following code pages 20284, 20924, 1140, 37, 500 and 20127.By working I...
|
by: Tim Wagaman |
last post by:
I an having issuses with a loop I am running to keep checking for
messages coming across our line.
The goal:
Listen for messages on port 5001 and print the messages into a text
file. The port...
|
by: Venkatarajan |
last post by:
hai,
At present I'm facing a strange problem. We are converting a project from
VB to .NET
One record contains Chr(0). Let the record be of length 1800. In the 50th
byte of a record a chr(0) is...
|
by: tvin |
last post by:
Hi all
I brought a string from a .txt file which was saved like utf-8.
In the .txt file i have this string "frédéric".My problem is that when i
read this file .txt,the bytes of é are like...
|
by: phpfreak2007 |
last post by:
Hi all,
I am trying to upload file using VB HTTP Post method and winsock control . Can successfully upload the files when client machine is English OS, but create problem when upload from Chinese...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |