Hi Gang,
I've created a text-based file format. Once I've generated the text to save
the file is as it should be in the debug window. However once I write it to
a file a " is added to the beginning and a ", to the end. Can somebody
explain why? I'm using VB2003.
Thanks in advance for any help,
Christian Blackburn
Here's my code:
Public Sub SaveGame(ByVal strDocument As String, Optional ByVal
bolShow_Dialog As Boolean = False)
'Saves the current game with or without showing a save as dialog
'Stores the Document Text to be saved
Dim strText As String
'Used to cycle through all the value X and Y coordinates of the table's
lights
Dim X As Integer
Dim Y As Integer
'If the user has requested to show a dialog or no file was specified show
the save dialog
If bolShow_Dialog = True Or strDocument = "" Then
objfrmMain.Save FileDialog.Titl e = IIf(strDocument = "", "Save Game",
"Save Game As")
objfrmMain.Save FileDialog.File Name = strDocument
If objfrmMain.Save FileDialog.Show Dialog() = DialogResult.OK Then
strDocument = objfrmMain.Save FileDialog.File Name
Else
Exit Sub
End If
End If
strText = "OriginalDocume ntName=" & strDocument & ";" & vbNewLine & _
"OriginalDocume ntModified=" & DateTime.Now & ";" & vbNewLine & _
"ProgramTit le=" & strAPP_TITLE & ";" & vbNewLine & _
"ProgramPat h=" & Application.Exe cutablePath & ";" & vbNewLine & _
"ProgramDateTim e=" & FileDateTime(Ap plication.Execu tablePath) & ";" &
vbNewLine & _
"DocumentVersio n=" & "1.03;" & vbNewLine & _
"PuzzleSize =" & "5,5;"
For X = 0 To 4
For Y = 0 To 4
If bolOn(X, Y) = True Then
strText = strText & vbNewLine & X & "," & Y & "=" & "1;"
Else
strText = strText & vbNewLine & X & "," & Y & "=" & "0;"
End If
Next
Next
Debug.WriteLine (vbNewLine & strDocument & ":")
Debug.Write(str Text)
'Opens our document for output, with write only access, and locks the
writability until we're done
FileOpen(1, strDocument, OpenMode.Output , OpenAccess.Writ e,
OpenShare.LockW rite)
'Writes the strText text to the file
FileSystem.Writ e(1, strText)
'Closes our handle to the file, allowing all programs to edit the file
FileClose(1)
strFile = strDocument
'Disables the Save Menu Option and Toolbar Button, because we just saved the
file so there couldn't be anything
'worth saving yet
objfrmMain.mnuS ave.Enabled = False
objfrmMain.Tool Bar.Buttons(2). Enabled = False
objfrmMain.Stat usBar.Text = strDocument & " saved."
End Sub 4 2547
[Hi Gang,
I thought I should mention way the file winds up looking:]
"OriginalDocume ntName=D:\Curre nt.EverybodyOn;
OriginalDocumen tModified=9/10/2003 9:57:24 PM;
ProgramTitle=Ev erybody On;
ProgramPath=D:\ Programming\VB. Net\EveryBody On\Source\Chapt er2\bin\Everybo dy
On.exe;
ProgramDateTime =9/10/2003 9:57:18 PM;
DocumentVersion =1.03;
PuzzleSize=5,5;
0,0=1;
0,1=0;
0,2=0;
0,3=1;
0,4=0;
1,0=0;
1,1=1;
1,2=1;
1,3=1;
1,4=1;
2,0=0;
2,1=1;
2,2=0;
2,3=0;
2,4=1;
3,0=0;
3,1=0;
3,2=1;
3,3=0;
3,4=1;
4,0=1;
4,1=1;
4,2=1;
4,3=1;
4,4=1;",
[Here's how it should look:]
OriginalDocumen tName=D:\Curren t.EverybodyOn;
OriginalDocumen tModified=9/10/2003 9:57:24 PM;
ProgramTitle=Ev erybody On;
ProgramPath=D:\ Programming\VB. Net\EveryBody On\Source\Chapt er2\bin\Everybo dy
On.exe;
ProgramDateTime =9/10/2003 9:57:18 PM;
DocumentVersion =1.03;
PuzzleSize=5,5;
0,0=1;
0,1=0;
0,2=0;
0,3=1;
0,4=0;
1,0=0;
1,1=1;
1,2=1;
1,3=1;
1,4=1;
2,0=0;
2,1=1;
2,2=0;
2,3=0;
2,4=1;
3,0=0;
3,1=0;
3,2=1;
3,3=0;
3,4=1;
4,0=1;
4,1=1;
4,2=1;
4,3=1;
4,4=1;
"Christian Blackburn"
I did not real search all of your code, but I think the error is in this
part. For X = 0 To 4 For Y = 0 To 4 If bolOn(X, Y) = True Then strText = strText & vbNewLine & X & "," & Y & "=" & "1;" Else strText = strText & vbNewLine & X & "," & Y & "=" & "0;" End If Next Next
When I see it right, you say everytime
a = a + n
a = a + n + a + n + a + n
etc.
I think you did mean something more like:
a = n + n + n
Dim temp as string
For X = 0 To 4
For Y = 0 To 4
If bolOn(X, Y) = True Then
temp = temp & vbNewLine & X & "," & Y & "=" & "1;"
Else
temp = temp & vbNewLine & X & "," & Y & "=" & "0;"
End If
Next
Next
strText = strText & temp
I hope this helps a little bit.
Cor
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb Hi Gang, I've created a text-based file format. Once I've generated the text to save the file is as it should be in the debug window. However once I write it to a file a " is added to the beginning and a ", to the end. Can somebody explain why? I'm using VB2003. Thanks in advance for any help, Christian Blackburn
[...]
FileOpen(1, strDocument, OpenMode.Output , OpenAccess.Writ e, OpenShare.LockW rite)
'Writes the strText text to the file
FileSystem.Writ e(1, strText)
'Closes our handle to the file, allowing all programs to edit the file
FileClose(1)
Have a look at the docs for FileSystem.Writ e. Whenever you write a string,
<"> is written before and after. You can write several values in the same
line into the file. They are separated by a ",". If your string also
contains a comma you can distinguish between the comma within a string and
the comma separating the values because the string is put in quotes. Use
FileSystem.Prin t instead (see it's docs for more information).
You can also create a FileStream (System.IO.File Stream) instead.
See also:
<F1>
Visual Studio.NET
Visual Basic and Visual C#
Reference
Visual Basic language
Visual Basic Language Tour
-> Processing drives, folders and files
.NET Framework
Programming with .NET Framework
-> Working with I/O
--
Armin
Yay,
Thanks again Armin. Your FileSystem.Prin t suggestion worked great.
Cheers,
Christian
"Armin Zingler" <az*******@free net.de> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. "Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb Hi Gang, I've created a text-based file format. Once I've generated the text to save the file is as it should be in the debug window. However once I write it to a file a " is added to the beginning and a ", to the end. Can somebody explain why? I'm using VB2003. Thanks in advance for any help, Christian Blackburn
[...]
FileOpen(1, strDocument, OpenMode.Output , OpenAccess.Writ e, OpenShare.LockW rite)
'Writes the strText text to the file
FileSystem.Writ e(1, strText)
'Closes our handle to the file, allowing all programs to edit the file
FileClose(1)
Have a look at the docs for FileSystem.Writ e. Whenever you write a string, <"> is written before and after. You can write several values in the same line into the file. They are separated by a ",". If your string also contains a comma you can distinguish between the comma within a string and the comma separating the values because the string is put in quotes. Use FileSystem.Prin t instead (see it's docs for more information).
You can also create a FileStream (System.IO.File Stream) instead.
See also:
<F1> Visual Studio.NET Visual Basic and Visual C# Reference Visual Basic language Visual Basic Language Tour -> Processing drives, folders and files .NET Framework Programming with .NET Framework -> Working with I/O -- Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Norvell |
last post by:
I just noticed that recently the javascript I was using to format and
display the last modified date of my web page is always reporting the
current date instead. It used to work fine. This is true both on the
university web server on which the page is hosted and the local mirror I
keep on my desktop (SuSE 8.2 Linux). It is a new university, but my
desktop filesystem is the same as before. I can see with "ls -l" that the
modified date of...
|
by: scott |
last post by:
Can someone help me my quotes in LISTING 2 below? LISTING 1 works fine in
HTML, but I'm having trouble with quotes in LISTING 2 near the javascript
code when trying to response write the entire button code.
LISTING 1: HTML
<INPUT TYPE=BUTTON VALUE="<< Previous <%=iMaxRecords%> Records"
ONCLICK="document.location.href='paging.asp?iPage=<%=iPage-1%>'">
|
by: asd987 |
last post by:
Hi,
I use document.write in a HTML-document to display same information. Now I
have a problem displaying text that sometimes contains two kinds of quotes
simultanelisly. I don't know on beforehand if this is the situation. See
example:
## ---
<script language="JavaScript">
|
by: Ron |
last post by:
Hello, I'm having an aggravating time getting the "html" spewed by Word
2003 to display correctly in a webpage.
The situation here is that the people creating the documents only know
Word, and aren't very computer savvy. I created a system where they
can save their Word documents as "html" and upload them to a certain
directory, and the web page dynamically runs them through tidylib using
the tidy extension to php4, thus causing the...
|
by: Ed |
last post by:
Hi,
I'm stuck at the moment trying to work out how to access the value of a
textfield which gets added in a DIV element.
I have functions to add and remove the textfields from the elements as
shown here:
function addListen(){
var ni = document.getElementById('listendiv');
| |
by: Jason |
last post by:
I have several tables with quite a few fields and I'm getting errors when
trying to insert records with single quotes in the data like: name = John
O'Henry or a city name of O'Fallen
So I went ahead and added a replace to replace the ' with " but now other
fields are having the same problem and there are multiple fields involved.
This data gets into having a lot of symbols used, etc.
So rather than go through and replace these quotes...
|
by: Dennis Fazekas |
last post by:
Greetings,
I am creating a web form which will all the user to add an unlimited number
of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to
remove, and a "Save" button. When the user clicks the "Add another email" it
will call a client side JavaScript function, add_email, which will
dynamically add a new set of controls to the webpage using the innerHTML
method. It appears to work perfectly fine in the browser. The...
|
by: Hank Moss |
last post by:
I've been able to get the <qelement and the CSS quotes property to
work well together in English, but not in Russian or mixed Russian and
English. I probably don't have a firm enough grasp of the CSS syntax
possibilities. This is exacerbated by the fact that I code in XHTML
1.1, where the <langproperty is not allowed (the xml:lang property
is used instead). My XHTML 1.1 pages contain both English and Russian
strings.
For Russian, I'm...
|
by: =?Utf-8?B?R2Vvcmdl?= |
last post by:
Hello,
I have some XML that is returned to my application from another vendor that
I cannot change before it gets to me. I can only alter it after it gets to my
application. That being said, I am having a problem loading the XML correctly
into my app.
Here is the code:
====================================
Dim sPaymentXML as String
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |