Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2004, 03:56 PM
Authorized User
 
Join Date: Jun 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Convert empty string to 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
 
Old June 8th, 2004, 03:52 AM
Authorized User
 
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think you'd need a function something like:

Code:
Public Function zerostringToNull(ByVal arg1 As String) As Variant
  Dim varOut As Variant
  varOut = Null
  If arg1 <> vbNullString Then
    varOut = arg1
  End If
  zerostringToNull = varOut
End Function
so
Code:
zerostringToNull("")
would return a Null value, but
Code:
zerostringToNull("My text")
would return a string
 
Old June 8th, 2004, 04:22 AM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to nano
Default

Thats just it, simple yet on target





Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing Double Quotes from a string Durkee VB.NET 2002/2003 Basics 12 October 4th, 2007 12:10 PM
Removing Double Qoutes from string hexOffender VB.NET 2002/2003 Basics 2 June 26th, 2006 02:44 PM
casting double to String. chikodi Servlets 2 October 23rd, 2003 02:50 AM
String to Double conversion mkpriya VS.NET 2002/2003 3 October 21st, 2003 05:26 AM
double to string? chris97b Visual C++ 4 September 23rd, 2003 02:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.