|
After I write it I usually let MSIE try to read it. If MSIE can't then my VB.NET will probably fail as well.
I can write is as Unicode. But MSIE will not be able to read it unless I change
encoding="utf-8"? to utf-16.
But this doesn't seem to be right. I would think that there should be an easier way just to write an XML block to disk without all the fuss.
Question: When the accented character is read from Web Services in VB6 the data looks and displays fine (the ü looks like a u with 2 dots). It is also written do disk and it still looks fine with Notepad. Then why is it that MSIE stops with an Invalid Character on ü. Is the enocoding in utf-8 different from ASCII.
What am I missing?
|
|
|
|
|
UTF-8 is different the ascii. Are you sure it is the ü that is causing your xml file to fail? Perhaps you are having other issues? If you want to send the bad xml file to me, you can sent it to ben.kubicek@netzero.com
Ben
|
|
|
|
|
Yes, I am sure. If I change the character to a normal u with notepad it works fine. I cannot send the file since it has customer info in it. But I removed all the data and created a small file with just 1 tag.
<?xml version="1.0" encoding="utf-8"?>
<tag>München</tag>
And MSIE fail on it. I will send the file via email also.
So this is saying that when I read the data from web services that the ü is now ASCII? Or when it is written to disk it is change to ASCII?
|
|
|
|
|
I put that text into a file called test.xml
I could open in it xmlspy with no issues or errors
I could run this code:
Dim doc As New XmlDocument()
doc.Load("c:\temp\test.xml")
again no issues or errors.
What is the exact error message you are getting again?
Ben
|
|
|
|
|
In MSIE
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
An invalid character was found in text content. Error processing resource 'file:///N:/accnt/CustomerFiles/MasterPiece/Err/x...
<tag>M
In VB.NET (using the real (big) file).
Invalid character in the given encoding. Line 63, position 2.
|
|
|
|
|
I think the issue in vb.net has to do with how you are reading the file.
what does your code look like?
Ben
|
|
|
|
|
The actual instruction is
Dim XRsave As XmlTextReader
XR = New XmlTextReader(TheFFn)
.
.
While (XR.Read())
I loops until it gets the the bad tag.
If it where vb.net then why can't MSIE read the file????
|
|
|
|
|
We're working with a byte variable and i am using it like a bitfield. To do this, i use BitArray class to avoid logical operations like and, or,...
My problem is when i want to reverse the operation. Starting from my BitArray object of size 8, is possible to convert to a single byte ?
Thanks.
|
|
|
|
|
I think that you can use the CopyTo method to copy the array into a byte array with a single element.
---
single minded; short sighted; long gone;
|
|
|
|
|
The BitArray class doesn't support conversions to other types (EDIT: I completely forgot about CopyTo!!).
If you're only using 8 bits, you're much better off just using a Byte and doing the bit manipulation yourself. It's easy to write your own methods to automate some of this, like setting or resetting a bit.
A quick little whip up:
Public Shared Function SetBit(ByVal value As Byte, ByVal position As Integer) As Byte
If position < 1 Or position > 8 Then
Throw New ArgumentOutOfRangeException("Position must be between 1 and 8.")
End If
Dim mask As Byte = CByte(2 ^ (position - 1))
If Not value And mask Then
value = value Or mask
End If
Return value
End Function
-- modified at 13:06 Wednesday 2nd May, 2007
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
hi there,
i made an application like notepad and i want when i click on any text file then my application should start so i select my application in open with and i coded in form1_load of my application
Dim newLine As String = ""
Dim cmdLine As String
open.InitialDirectory = System.Environment.SpecialFolder.Desktop
If InStr(System.Environment.CommandLine, ".txt") Then
cmdLine = System.Environment.CommandLine
Dim charInLine As String
Dim quoteCharStop As Integer = 0
Dim placeInString As Integer = cmdLine.Length - 1
While quoteCharStop < 2 And placeInString > 0
charInLine = cmdLine.Substring(placeInString, 1)
If charInLine = Chr(34) Then
quoteCharStop = quoteCharStop + 1
Else
newLine = charInLine & newLine
End If
placeInString = placeInString - 1
End While
Try
If File.Exists(newLine) Then
Dim o As StreamReader = File.OpenText(newLine)
Text1.Text = o.ReadToEnd()
o.Close()
End If
Text1.SelectionStart = 0
Text1.SelectionLength = 0
Catch
End Try
savechk = False
End If
its working but when i open large file the application appear blank(i.e. rich text box blank)
someone know the solution??
i also want to code a button as when i click on then it should change open with program to mine application
|
|
|
|
|
Well, your code is looking for ".txt" on the command line. That's a bad assumption to make. If should just open the file it's given, no matter what the extension is. You're also trying to parse up the command line when you really don't have to. There's a method on the Environment class that returns al the command line arguments already parsed up:
Dim args As String() = Environment.GetCommandLineArgs()
If args.Length > 1 Then
' There's at least one argument, besides our .EXE filename
' Treat the first argument as a filename and try to open it as text file.
LoadFile( args(1) )
End If
.
.
Private Sub LoadFile(ByVal filepath As String)
Try
If File.Exists(filepath) Then
Text1.Text = File.ReadAllText(filepath)
Else
Throw New FileNotFoundException(String.Format("The filepath {0} was not found!", filepath))
End If
Catch ex As Exception
' Not exactly "good practice", but this works for this example...
Throw ex
End Try
End Sub
Now, if you're using a RichTextBox, there is no maximum size of text that can be read. If you're using a TextBox, you might want to check the MaxLength property and set it to 0 to indicate that there is no limit to maximum length of text in the box.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
hey thanks, its working, thats really good i did alot of coding to get that path ,i also tried Environment.GetCommandLineArgs() but i didnt knew what is this and how to use it?
to open text files i always use rich textbox because it have more functions than textbox
1 question::
i didnt understand that how the value\file path come in this variable(filepath)...????
Private Sub LoadFile(ByVal <code>filepath</code> As String)
buddy i have another question thst is
when i click on a button then it should change open with program to mine application
|
|
|
|
|
xmen_xwk wrote: i didnt understand that how the value\file path come in this variable(filepath)...????
Private Sub LoadFile(ByVal filepath As String)
This is what the calling code has to pass into this method. Seriously, if you're asking this question, you really need to pickup a book on VB.NET for Beginners. This is 2nd day of class stuff.
xmen_xwk wrote: when i click on a button then it should change open with program to mine application
This is done outside of your application, normally by the installer for your application.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
oh yeah but i couldn`t see that line properly where the calling code....
and to change 'open with' program then i want to know how to do that?
|
|
|
|
|
Hi,
I'm just adding (another) final piece to my app which involves printing. Okay, not much fun but, been there before and bought the T-shirt.
Okay, it seems to work, I'm printing exactly what I expect to see on an HP LaserJet.
I've got a PrintDialog component to allow me to select the printer. I select a second printer, Epson,(rather than the default HP) and all I get is a pile of blank pages. Have to cancel the document, turn off the printer and wait 5 minutes.
If I swap the default printer to the Epson, same thing happens on that printer but I can use the PrintDialog to select the HP which as before, works fine. So the PrintDialog appears to be working.
Stepping through the PrintDocument method, the strings being "printed" appear to contain the correct data - in short, the method looks to be doing exactly what it should (as it must, as I can print on the HP).
Print preview works fine whichever printer is selected.
When the Epson is reset, I can print a test page okay from Word.
So, to summarise:
1) The Epson printer works
2) The PrintDocument1.Print method works
3) The Printdialog works
4) The Print preview works.
So why can't I print on the damn Epson?
Post script:
Another part of my project which has been tested to death, allows the selection of a printer. Just tried a test print with this and got the same thing - endless blank pages on the Epson. The code here has not been changed and used to work fine.
Any ideas anyone?
Cheers,
Rich
|
|
|
|
|
Odd. Is the Epson printer setup with a text only driver?
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
No it's not. As it happens, I'm only printing text anyway.
I have had an Epson printer behave strangely in the past but turning it off and re-starting Windows has always worked in the past. Not this time.
May turn everything off for half an hour and try again as I can't see anything to indicate that the App is at fault.
Cheers,
Rich
|
|
|
|
|
I've partly solved it!
Just realised that the printer I was selecting isn't the model installed - it's one we don't use anymore and the model numbers are so similar I didn't realise.
However, this fails to explain why the Dialog box fails to pick up the real printer that is attached and works from other apps!!
Rich
|
|
|
|
|
Hi can any one tell me how to show only one open window of the application even if it contains multiple windows.
Example i have 5 forms in the project and when i open the form while running it shows multiple opened windows on the taskbar, where as i need only 1.
Jats
|
|
|
|
|
If you go to the design view of your form theres a ShowInTaskbar Option, set it to False for the Forms you dont want to show in the Taskbar.
" In the next millennium there are two kinds of business, those on the Internet and those out of business"
Bill Gates
"Be nice to nerds. Chances are you'll end up working for one."
Bill Gates
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
Have you seen the ShowInTaskbar property of the Form class?
Dim newForm As New Form2
newForm.ShowInTaskbar = False
newForm.Show()
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
hi jats
First u decide which form's title must be show in task bar .
if u want to show same form title for all condition, then change the property ShowInTaskBar to false for all other remaining form.
and if u want to show different title for different form at the base of active form(but have only one window in task bar) then set ShowInTaskBar property to false for all other form at load event of present active form.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
Hi there,
I have a VB MFC that uses a dll for sending, receiving, dispalying and logging data from/to another application the problem is that SOMETIMES when I close the VB window by clicking on X the application goes off ( you do not see it on desktop) but when you open the task manager, you can see that the application is still there. The problem is that it happens just sometimes. Any ideas?
It is the way I close the appliaction:
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Are you sure you want to Exit the application?", vbYesNo + vbQuestion, "Application") = vbNo Then
Cancel = True
End If
End Sub
Private Sub MDIForm_Terminate()
fnWEHostShtdn
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, "Settings", "MainLeft", Me.Left
SaveSetting App.Title, "Settings", "MainTop", Me.Top
SaveSetting App.Title, "Settings", "MainWidth", Me.Width
SaveSetting App.Title, "Settings", "MainHeight", Me.Height
End If
End Sub
The other question is that how I can check if an application is running and if for any reason (even a hard close by user) the application is closed, it reopens itself.
Thanks in advanced.
Nahitan
|
|
|
|
|
This is usually caused by an improper shutdown of a component in your app. Most likely, this would be the .DLL you're using. It's possible that it created a seperate thread(s) that are still running when your app quits. You'll have to check with the docs or anything else you can find on this library and see if it needs you to do anything special to shut it down before your app closes.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|