Forcing data types..

Results 1 to 6 of 6

Thread: Forcing data types..

  1. #1
    Al Bear Guest

    Default Forcing data types..

    How can I set what type of data a varable will hold????

  2. #2
    Sid Guest

    Default RE: Forcing data types..

    Try<BR><BR>Dim myVar As String<BR>Or<BR>Dim myVar As Integer<BR><BR>etc<BR><BR>HTH<BR>Sid

  3. #3
    Mike Shaffer Guest

    Default RE: Forcing data types..

    If you are talking about ASP using VBScript, you really can&#039;t. All variables are variants, meaning they can &#039;hold&#039; anything. You can force data type by using the various type conversion functions (e.g. cdate, cint, cstr, etc.)<BR><BR>Now, ASP+ has support for other language models that *do* support strong typing of variables.<BR>

  4. #4
    Mike Shaffer Guest

    Default RE: Forcing data types..

    This code will fail. You cannot specify a data type using ASP VBScript (but you CAN using ASP+ or by casting your code as a component in VB, C++, etc.)

  5. #5
    AL Bear Guest

    Default Oh yes you can!

    varable = cint(varable) make varable integer<BR>varable = cstr(varable) make varable a string<BR><BR>took a while but I got there in the end......

  6. #6
    Mike Shaffer Guest

    Default No, you can't

    Not the way that Sid explained. And there is no way to &#039;enforce&#039; the data type rule for a particular variable, and that is what I felt you were asking. If you had read my earlier message, you would have seen the references to CINT and CSTR, etc.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts