relpacing blank spaces with comma

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2008
Posts: 63
Reputation: love_dude1984 is an unknown quantity at this point 
Solved Threads: 2
love_dude1984 love_dude1984 is offline Offline
Junior Poster in Training

relpacing blank spaces with comma

 
0
  #1
Apr 30th, 2009
hello frendz..

im working on a small application wher i need to copy the data from excel sheet and paste it to the text file.im trying to create a macro for tht.
the selected row should be in a specific format. like if ther r 3 colums then the text should be saved in text file with comma's like a,b,c.

uptil now, im able to save the file with the data which contains blank spaces. how can i remove those blank spaces and insert a comma ther i tried using the following code..but its not working..plz help me solve this prob??

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Open "C:\temp.txt" For Input As #1
  2. astring = Input$(LOF(1), 1)
  3. Close #1
  4.  
  5. astring = Replace(astring, " ", ",")
  6. MsgBox astring 'to check if values are correct
  7.  
  8. Open "C:\temp.txt" For Output As #1
  9. Print #1, astring
  10. Close #1

thnx in advance
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 141
Reputation: jonifen is an unknown quantity at this point 
Solved Threads: 15
jonifen jonifen is offline Offline
Junior Poster

Re: relpacing blank spaces with comma

 
0
  #2
May 1st, 2009
You say you want to read from an Excel sheet to a text file, but your code shows you opening a text file for input. I don't know how you usually read from an Excel sheet, but I don't think you can open it like a text file as your code suggests...
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 894
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: relpacing blank spaces with comma

 
0
  #3
May 2nd, 2009
Perhaps those "spaces" you are talking about are actually "tab" characters. Try replacing with vbTab instead of " ".

Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 63
Reputation: love_dude1984 is an unknown quantity at this point 
Solved Threads: 2
love_dude1984 love_dude1984 is offline Offline
Junior Poster in Training

Re: relpacing blank spaces with comma

 
0
  #4
May 4th, 2009
ya..vbTab works fine..thanks for the help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC