Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old August 13th, 2004, 05:52 AM
Danny20 Danny20 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 13 Danny20 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Exporting Strings to a file without the Inverted Commas

I have created a program , really simple one to open a text file and to save strings to it

Dim strDataField,strDataField1,strDataField2,strDataFi eld3As String

Open "test\" + filename.Text + ".txt" For Output As #1 'location of the file.
Write #1, strDataField, 'The things you want to save"
Close 1

so the out of the file is like the following

"Halloo" , " Ashoor" , "Null ", and so on

so how i ant get rid of the inverted commas in the string since i have alot of strings inside the file

or is there away to convert the string or so

Reply With Quote
  #2  
Old August 13th, 2004, 07:16 AM
spak111 spak111 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 349 spak111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 25 sec
Reputation Power: 5
Send a message via AIM to spak111
What exactly do you mean 'inverted' commas? Whenever you write to a sequential file using VB 6.0, it will be comma delimmited and all strings will have quotes (") around them. Numbers will not have quotes around them. Exactly what are you asking for so that we may be able to give you a more complete answer.

Reply With Quote
  #3  
Old August 13th, 2004, 08:01 AM
Danny20 Danny20 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 13 Danny20 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

am sorry sicne i didnt put my question in the right manner

I have done a program which takes values of strings and write them to

a file. The file output is the followin below



"101363 ","NUD","RTA"

so my question is how to get red off the Two Quotes in the string

i know this is becuase VB6 functionality but is there a way to get red of them

regards and thanks for your help

Reply With Quote
  #4  
Old August 16th, 2004, 09:11 AM
Mythomep Mythomep is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Zaandam, The Netherlands
Posts: 70 Mythomep User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 37 sec
Reputation Power: 4
Send a message via MSN to Mythomep
Cool

Hi,

Instead of using the Write function, use the Print function on the file.

Code:
  Print #hFile, sExportLine


That should get rid of the quotes around the strings. Then some other things...
  1. You use #1 in your file open statement. That is realy bad, since it might be possible that you opened up another file with #1 somewhere else in your code. Use the following to make sure you open a new file without a conflict:

    Code:
      Dim hFile as Long ' A variable that contains our file handle.
      hFile = FreeFile ' Get a free filenumber.
      Open "C:\Temp\Test.txt" for input as hFile ' open the file.
  2. Please concatenate strings with the & (ampersand) sign, not the + (plus) sign. Using a plus sign can cause unpredictable results (in some cases it can do a sum on two strings that contain numbers).
  3. Explicitly type all the variables. Dim strField, strName, strSomething as string will only dim the last one as a string. All the other ones are variants (they are evil most of the times).
  4. Use error handling to close the file. Something along the lines of this:

    Code:
    Private Sub Test()
      Dim hFile as long
    ' -------------------
      On Error GoTo PROC_ERR
      
      ' Do you stuff.
    
    PROC_EXIT:
      If (hFile <> 0) then
    	Close hFile
      End If
    
    PROC_ERR:
      Select Case Err.Number
      Case Is <> 0
    	Msgbox "An error occured"
    	Err.Clear
    	Resume PROC_EXIT
      End Select
    End Sub
That should make your code a bit more stable and not prone to errors. Any questions, feel free to ask.

Grtz.©

M.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Exporting Strings to a file without the Inverted Commas


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway