|
I am new to vb.net and having great difficulties writing out a PCL file. I am reading it fine.
The best article I have read anywhere was on this site
http://www.codeproject.com/vb/net/vb_file_handling.asp
but still not understanding streamreader,streamwriter,binaryreader,binarywriter,filestream. It would be great if i could see an example of code that reads PCL by vbCRLF or even by the page, and writes it back out to another file without PCL changing!
Thanks much!
|
|
|
|
|
So what does a PCL file look like?? Are you talking about the page description language commonly used for HP's laser printers??
|
|
|
|
|
You are correct HP Printer Control Language.
The file would be a mix of ASCII text and binary bits for fonts, graphics, control codes etc.
a string in (bold) (hex not bold) may look like:
2A743330 30521B2A 72343133 73383854 1B2A7231 411B2A62 324D1B2A 623657D5 *t300R.*r413s88T.*r1A.*b2M.*b6WÕ
00FFFFFB 001B2A62 3857D600 0001FFFF FB001B2A 623857D6 000201FF FEFB001B .ÿÿû..*b8WÖ...ÿÿû..*b8WÖ...ÿþû..
same string out ends up like:
2A743330 30521B2A 72343133 73383854 1B2A7231 411B2A62 324D1B2A 623657EF *t300R.*r413s88T.*r1A.*b2M.*b6Wï
BFBD00EF BFBDEFBF BDEFBFBD 001B2A62 3857EFBF BD000001 EFBFBDEF BFBDEFBF ¿½.���..*b8W�...��ï¿
So upto the byte before hex D5 in this case everyting is OK after that its downhill. Several different approaches with litte difference although using example below changing Default to ASCII and all the other options had some effect but not good.
Dim btFile As Byte()
btFile = System.Text.Encoding.Default.GetBytes(sText)
Where sText was the input string from reading the pcl.
|
|
|
|
|
PCL is a binary format, not a mix of binary and text. It just APPEARS as text in places.
You have to use the BinaryReader/BinaryWriter classes to read/write these files. Open a FileStream on the file itself, then use a BinaryReader to read the data from that stream, byte-by-byte. There is no CrLf that is a line terminator. None of the encodings will work on this file, that I know of anyway.
|
|
|
|
|
Thank you Dave,
So far i found must use both binaryreader and binarywriter (i know i know but i don't need to alter any of the binary bytes) i could not simply use streamreader to read a line in (there are vbcrlf in there works fine since the days of qbasic) and binarywriter to write out the string because string was already corrupted by streamreader. this is now a slowed down compared to vb6 due to byte by byte processing. I'll have to re-examine my test and post the little code later for better/faster reading writing.
|
|
|
|
|
I am trying to write an SQL statement in .Net to fill a listview. The SQL statement retreives information from two tables. The problem I am having is that one of the keys (subjob) can have a null value. Any records where the second key is null are not retrieved. I found a note on the internet indicating the following;
Programmers should take special care when joining tables on columns that can contain NULL values, since NULL will never match any other value (or even NULL itself), unless the join condition uses explicitly the IS NULL or IS NOT NULL predicates.
Can someone please show me where the ISNULL should go to fix this SQL statement.
SELECT Ordmstr.OrdNum, Ordmstr.JobNum, Ordmstr.SubJob, JobMstr.JobDesc
FROM Ordmstr INNER JOIN JobMstr ON (Ordmstr.JobNum = JobMstr.JobNum) AND (Ordmstr.SubJob = JobMstr.SubJob)
Thank you.
digicd1
|
|
|
|
|
Which table contains records where SubJob can be NULL?
If it is Ordmstr, the following should work:
SELECT Ordmstr.OrdNum, Ordmstr.JobNum, Ordmstr.SubJob, JobMstr.JobDesc
FROM JobMstr LEFT JOIN Ordmstr
ON (Ordmstr.JobNum = JobMstr.JobNum)
AND ((Ordmstr.SubJob = JobMstr.SubJob) OR Ordmstr.SubJob IS NULL)
Paul Marfleet
|
|
|
|
|
Both tables have nulls. Every Order has a record in the Job Master table. The key to the Job Master is Job/Sub Job. For whatever reason, when the application was originally developed, the programmer used null in the sub job if there was not a value. This is also carried onto the Order Master table.
Job Sub Desc
00100 Null ABC
00100 100 DEF
00200 Null GHI
00201 100 JKL
Again, when the tables are joined - the only records that are retrieved are thos where the subjob is not null.
digicd1
|
|
|
|
|
Use the ISNULL function as a wrapper around the each field when specifying the join between the 2 Subjob fields. Use the same default value in both cases. This will eliminate the NULL values and allow your original query to work.
Paul Marfleet
|
|
|
|
|
How can I code to get a calculated answer which is shown in a textbox to a listbox, and further answers added to that list box.
|
|
|
|
|
Your question doesn't provide any details, but you add a string, even if it's the result of a calculation, to a listbox by doing something like:
Dim result As Integer = x * y
ListBox1.Items.Add(result.ToString("N"))
|
|
|
|
|
I have the product of a quantity and price (both doubles) to give total
dim total as double
the total is then displayed in a textbox when a button is clicked.
How would I get this result (total) in a listbox by clicking a button, and other subsequent results into that listbox.
What is "N" in your above response
Thank you
|
|
|
|
|
It works thanks a million.
With the totals displayed in the listbox, how can I find the total of the
numbers displayed to with two decimal places
|
|
|
|
|
"A fatal error has occurred and debugging needs to be terminated...."
Thanks
|
|
|
|
|
That depends on what you're debugging at the time. Is it managed code?? native code?? An ASP.NET app?? Windows Forms app?? Compact Framework app?? Is this debugging code from your workstation that is running on a mobile device??
Without some more detail, about the only thing anyone can do is point you at Google and start searching for the error message.
|
|
|
|
|
|
Could be a wide variety of things and without seeing the code where it happens, I really cannot tell you.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
For the following lines of VB6 code i get error in vb.net. I am trying to convert the following code to VB.NET.. Can anyone help .Thanks in advance.
Dim FileBuf As String * MSG_DATA_LEN
On Error GoTo OpenFailed
Open sFile For Binary As #1
LSet(FileBuf = sMsgData + MSGDATA_END_MARKER)
Put #1, MSG_DATA_FILE_OFFSET, FileBuf
Close #1
bResult = True
Exit Sub
OpenFailed:
bResult = False
End Sub
--------------------
Errors i got:
'Put' is not declared. File I/O functionality is available in the 'Microsoft.VisualBasic' namespace.
'Open' is not declared. File I/O functionality is available in the 'Microsoft.VisualBasic' namespace.
|
|
|
|
|
Forget this old method for File I/O functionality use the new managed classes under System.IO namespace e.g. by using StreamReader you can easily read a file by using the following code:
Try
Dim Data as String = ""
Dim sr as new System.IO.StreamReader("FileName")
Data = sr.ReadToEnd()
sr.Close()
Msgbox(Data)
Catch Ex as Exception
Msgbox(Ex.ToString())
End Try
AliAmjad(MCP)
|
|
|
|
|
Thanks for your reply,
and what is the equivalence of the following code in vb.net?
Global Const SQL_SUCCESS = 0
thanks
|
|
|
|
|
Hi,
You can use Public Const SQL_SUCCESS = 0 in VB.Net 2005.
You may put this code in a Module to make it Global to your application.
I hope this helps.
-- modified at 9:02 Thursday 1st November, 2007
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
I am writting a car PC project and have got to the last bit now, the DVD player.
I started using WMP, but it has limited functionality, and I was told to try DirectShow which I didn't understand. SO MSWebDVD was my option, as it seems really easy, apart from one problem I have.
How do you tell MSWebDVD what drive you want to use, it only uses one of my drives. I also want to play movies from my hard disk, but using the code:
MSWebDVD.dvdidrectory = "c:\dvd\video_ts"
only works if there is a DVD in the DVD drive, why is this?
Surely you don't have to have a disk in the DVD drive to enable MSWebDVD to play a DVD folder on the hard disk.
Thanks for any sugestions
Craig
|
|
|
|
|
As far as I can tell, it will only work with DVD volumes, not non-DVD drives. That property sets the current video root of a DVD volume, which can have multiple roots in various directories on the disk.
|
|
|
|
|
But why do you have to have a disk in one of the drives, and with 2 DVD drives, which one is the one that it uses?
DirectShow can be used to play DVDs, can anyone post a small code snippet to get me started, as I don't understand all the filter graph stuff that I was reading on the Microsoft site.
Thanks again
|
|
|
|
|
Hi I am converting a project fromVB6 to vb.net the following line gives an error, Can anyone tell me how to fix it?
Private Sub Form_Load()
Load(AccessForm)
Load(LeaveMsgForm)
The error I get is:
'Public Event Load(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
|
|
|
|