Re: Text as argument to Randomize function

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"johngross" <johngross@xxxxxxxxxxxxxxx> wrote in message
news:66cf83d0-e423-4cc2-bf20-af067a68e261@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I would like to be able to use text (as a string) as the argument for
the Randomize function.

The VBA Help says that the argument is of type Variant, which - as I
understand it - includes strings. I'e tried to do this in various
ways, but none of them seems to work; the closest I get is when an
error message tells me that an argument of this type must be in an
object module.

Is what I want to do possible?

If so, can anyone point me in the direction of how to do it?

Regards to all,

johngross

The documentation is a bit confusing here .. the argument can be "a Variant"
as long as that Variant evalutes to a "valid numeric expression".

If you have a String value that represents a number (eg, "00345", "123",
"23.5", ...) then use a Conversion function on it such as CLng(StringValue)
or CDbl() depending on scope.
If you are using a string such as "abcde" then you will need to run some
kind of hash on it to turn it into a number. (But my guess is you have the
former.)

-ralph


.



Relevant Pages

  • Re: NZ Example from MLH
    ... MLH made no such claims. ... Nzreturns a variant of subtype string (which you continually ... strings (the subtype of a value stored in a variant controls what ... VBA data type, as you point out in another post). ...
    (comp.databases.ms-access)
  • Re: Low/High Values equivalent in Visual Basic
    ... If your strings cannot start with Chror Chr, ... routines that accept a Variant and return a Variant. ... 'Dim int16 As Integer ... Dim sTemp As String ...
    (microsoft.public.vb.general.discussion)
  • Re: Dumme Frage zum Thema DLL-Aufruf
    ... Nimm statt dessen einfach PChar. ... Mir scheint auch weniger die Übergabe des Strings problematisch zu sein, ... Ich deklariere OLE-Objekte immer als Variant. ... Next by Date: ...
    (de.comp.lang.delphi.misc)
  • Community Nugget 3-12-2007 Implementing sets with variant attributes
    ... Sets are like arrays with no duplicate values and where order of the elements is ignored. ... as a new attribute name to a variant using Set ... automatically guarantees that there are no duplicate strings in the set. ... attributes in a set as a alphabetically sorted array. ...
    (comp.lang.labview)
  • Re: Invalid Use of Null Error
    ... Make your variables of type Variant. ... Nulls and empty strings, because Variants are less efficient to process. ... > i am trying to get data from a record set. ...
    (microsoft.public.access.formscoding)