Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Convert an empty string to a double

Hello:


Is there a way to convert an empty ("") string variable to
a NULL (NOT a zero) double variable. I have tried the Val
function and CDbl function. The first one gives me
a 'zero' double variable. The second one gives me a run-
time error.


Thank you,
Adrian T


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Convert an empty string to a double

Well... no. But what are you trying to accomplish? If you declared you
variable as a string than that variable is always going to be a string
If your variable is undeclared ad you assign it a value of "Null" i
will just be of type Variant/Null. You could just assign a differen
Double a value of "Null." Does that work? - Piku

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Convert an empty string to a double

Basically what I am doing is to assign values from a
delimited text (seperated by semicolons) into an array
with the Split function. The array will be in String by
default and will be useless since I am looking for doubles.

The challenge occurs when the text file passes a null
value (blank) for missing elements, for example:
300;540;;780;;600 and so on. Positions are very important
here, so having a blank after 540 is very important as
saying the third element is null (NOT a zero since zero
means number 0).
The code needs to determine how many loops to be called.
In this case, the loop calls 300 and 540 as double values,
which are easy to convert to (from the string array). But
the third element will give me a zero value (not NULL)
after I try to convert it from a string. The loop now will
call all three elements, 300,540 and 0, which would be
wrong.


Well..I guess I have to manipulate the way how the code
calls for loops. It's just nice if there is a function
that could convert "" to a NULL double.


Thank you,
Adrian T




-----Original Message-----
Well... no. But what are you trying to accomplish? If

you declared your
variable as a string than that variable is always going

to be a string.
If your variable is undeclared ad you assign it a value

of "Null" it
will just be of type Variant/Null. You could just assign

a different
Double a value of "Null." Does that work? - Pikus


---
Message posted from http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Convert an empty string to a double

"Adrian T" wrote...
...
Well..I guess I have to manipulate the way how the code
calls for loops. It's just nice if there is a function
that could convert "" to a NULL double.

...

You are *FAILING* to understand that there isn't any NULL double in VB[A]. If
your variable is of type Double, then it can only contain available numeric
values because VB[A]'s Double type won't/can't store IEEE floating point
exception values or anything other than numeric values. So, if you're using
Double type, you can't do what you want to do - PERIOD. If you're using Variant
type, you can store NULL values in them, as well as strings and various other
junk, but you'll need to use VB[A]'s IsNull function to screen them out.

There may be several ways to improve your code, but you haven't been willing yet
to offer it up for scrutiny. Too damn much guesswork without your original code,
so the only answer to give you is, "yes, you'll have to modify your code."

--
To top-post is human, to bottom-post and snip is sublime.
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
Empty excel files when double click on them Luca Fabbri Excel Discussion (Misc queries) 1 October 24th 05 02:53 PM
How can I convert empty strings to empty cells? Shane Excel Discussion (Misc queries) 2 July 19th 05 12:10 PM
double quotes around string in formula craeted in vba tegger Excel Programming 4 November 21st 03 06:17 PM
Can blank cells created using empty Double-Quotes not be empty?? JohnI in Brisbane Excel Programming 6 September 7th 03 11:22 PM
Formatting Problem on Double-Zero String Tom Ogilvy Excel Programming 1 July 18th 03 06:56 PM


All times are GMT +1. The time now is 02:31 PM.

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

About Us

"It's about Microsoft Excel"