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 1762
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: 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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |