Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Using TAB as CSV delimiter

Hi guys,

What's the difference between to two vbConstants:

- vbTab - Chr(9) and
- vbKeyTab - Chr(57)

Which one will be the most corrent to use as delimiter in a .CSV file?

Thanks,

CE



---
Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret.
http://www.avast.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Using TAB as CSV delimiter

Hi guys,

What's the difference between to two vbConstants:

- vbTab - Chr(9) and
- vbKeyTab - Chr(57)

Which one will be the most corrent to use as delimiter in a .CSV
file?

Thanks,

CE



---
Denne e-mail er fri for virus og malware fordi avast! Antivirus
beskyttelse er aktiveret.
http://www.avast.com


Hi Charlotte,
I've always used vbTab and so can vouch that it works reliably. I'm not
familiar with vbKeyTab and so can't speak to its usage in place of
vbTab.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Using TAB as CSV delimiter

GS wrote:

What's the difference between to two vbConstants:

- vbTab - Chr(9) and
- vbKeyTab - Chr(57)

Which one will be the most corrent to use as delimiter in a .CSV
file?


Hi Charlotte,
I've always used vbTab and so can vouch that it works reliably. I'm not
familiar with vbKeyTab and so can't speak to its usage in place of
vbTab.


vbTab is correct, because that's the ASCII code for the tab character.
(Chr(57) = "9".)

vbKeyTab is the scan code for pressing the Tab key on the keyboard (a
completely unrelated task), largely used in forms, like this:

Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If vbKeyTab = KeyAscii Then MsgBox "Tab"
End Sub

--
[Gerald] Ford had only one major fault -- he was too nice a guy.
-- Bob Hartman, Ford's speechwriter
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Using TAB as CSV delimiter

GS wrote:

What's the difference between to two vbConstants:

- vbTab - Chr(9) and
- vbKeyTab - Chr(57)

Which one will be the most corrent to use as delimiter in a .CSV
file?


Hi Charlotte,
I've always used vbTab and so can vouch that it works reliably. I'm
not familiar with vbKeyTab and so can't speak to its usage in place
of vbTab.


vbTab is correct, because that's the ASCII code for the tab
character. (Chr(57) = "9".)

vbKeyTab is the scan code for pressing the Tab key on the keyboard (a
completely unrelated task), largely used in forms, like this:

Private Sub UserForm_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger) If vbKeyTab = KeyAscii Then MsgBox "Tab"
End Sub


Thanks! That makes sense since KeyAscii would be the right place for
using vbKey<whateve because we would be testing a keyboard action! I'm
not familiar with vbKeyTab because the only keyboard action I test for
is when the ESC key is pressed, and I always use the numeric value
rather than the VB constant.

Also, vbTab is a printable string character and so makes sense that it
would be used for delimiting a string!<g

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Using TAB as CSV delimiter

GS wrote:

GS wrote:

What's the difference between to two vbConstants:

- vbTab - Chr(9) and
- vbKeyTab - Chr(57)

Which one will be the most corrent to use as delimiter in a .CSV
file?

Hi Charlotte,
I've always used vbTab and so can vouch that it works reliably. I'm
not familiar with vbKeyTab and so can't speak to its usage in place
of vbTab.


vbTab is correct, because that's the ASCII code for the tab
character. (Chr(57) = "9".)

vbKeyTab is the scan code for pressing the Tab key on the keyboard (a
completely unrelated task), largely used in forms, like this:

Private Sub UserForm_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger) If vbKeyTab = KeyAscii Then MsgBox "Tab"
End Sub


Thanks! That makes sense since KeyAscii would be the right place for
using vbKey<whateve because we would be testing a keyboard action! I'm
not familiar with vbKeyTab because the only keyboard action I test for
is when the ESC key is pressed, and I always use the numeric value
rather than the VB constant.


vbKey<X is useful for avoiding magic numbers. Writing your code now, you
know that 27 is Escape (or whatever), but a month from now? A year? Unless
you normally carry those values in your head, it's best IMO to use the
constants.

Also, vbTab is a printable string character and so makes sense that it
would be used for delimiting a string!<g


Yeah, precisely. Upon reviewing the docs, it looks like vbKeyTab = 9, not 57
as Charlotte posted. Not entirely sure where that number came from. Maybe
the scan codes are different for non-US keyboards, I dunno.

--
Is my phone number 1-800-DO-MY-JOB?


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Using TAB as CSV delimiter

vbKey<X is useful for avoiding magic numbers. Writing your code now,
you
know that 27 is Escape (or whatever), but a month from now? A year?
Unless
you normally carry those values in your head, it's best IMO to use
the
constants.


Yeah, you make a valid point! Yes, the ESC key # is 27 and since it's
the only one I use it's easy to remember. However, I do feel that using
the constant makes code more self-documenting and so I should change my
habits to that end.

And yes, you're correct that vbKeyTab = KeyAscii(9)!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Using TAB as CSV delimiter

GS wrote:

vbKey<X is useful for avoiding magic numbers. Writing your code now,
you know that 27 is Escape (or whatever), but a month from now? A year?
Unless you normally carry those values in your head, it's best IMO to use
the constants.


Yeah, you make a valid point! Yes, the ESC key # is 27 and since it's
the only one I use it's easy to remember. However, I do feel that using
the constant makes code more self-documenting and so I should change my
habits to that end.


I strongly recommend it -- but OTOH, in some of my old VB6 projects, I used
various keys in such a way that it was common to see something like this:

Select Case KeyCode
Case vbKeyTab
Case vbKeyLeft
Case Asc("W")
End Select

--
Power... immense power, so absolute...
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Using TAB as CSV delimiter

GS wrote:

vbKey<X is useful for avoiding magic numbers. Writing your code
now, you know that 27 is Escape (or whatever), but a month from
now? A year? Unless you normally carry those values in your head,
it's best IMO to use the constants.


Yeah, you make a valid point! Yes, the ESC key # is 27 and since
it's the only one I use it's easy to remember. However, I do feel
that using the constant makes code more self-documenting and so I
should change my habits to that end.


I strongly recommend it -- but OTOH, in some of my old VB6 projects,
I used various keys in such a way that it was common to see
something like this:

Select Case KeyCode
Case vbKeyTab
Case vbKeyLeft
Case Asc("W")
End Select


I started using this line in the _Keypress event on forms...

If KeyAscii = 27 Then Unload Me 'Esc

...as the default in my form template, which was formatted for font and
had the basic Ok/Cancel buttons placed. I just did copy/paste to insert
the line in other _Keypress events.

As of now the form template has been modified as follows.

If KeyAscii = vbKeyEscape Then Unload Me

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Using TAB as CSV delimiter

Hi Guys,


Sorry for a late reply, but I've been away for a few days :-)

But, thank you for your replys - everything makes sense now :-)


CE


"Charlotte E." wrote in message
...
Hi guys,

What's the difference between to two vbConstants:

- vbTab - Chr(9) and
- vbKeyTab - Chr(57)

Which one will be the most corrent to use as delimiter in a .CSV file?

Thanks,

CE



---
Denne e-mail er fri for virus og malware fordi avast! Antivirus
beskyttelse er aktiveret.
http://www.avast.com




---
Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret.
http://www.avast.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TTC delimiter restriction inequitude Excel Discussion (Misc queries) 2 November 12th 10 11:20 PM
CSV - no delimiter at end of line cats_five Excel Discussion (Misc queries) 1 March 19th 10 09:25 AM
delimiter hughie Excel Programming 2 December 21st 06 01:17 PM
Text to Row by Delimiter betty77[_3_] Excel Programming 2 August 5th 06 05:29 AM
Tab Delimiter File moonwalker Excel Discussion (Misc queries) 7 February 24th 06 03:56 PM


All times are GMT +1. The time now is 01:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"