[BNM] 2 questions of ASP/VB

David Elliott the1gadget at gmail.com
Mon Apr 10 22:26:21 BST 2006


Hi All

On 4/10/06, Dave Child <dave at ilovejackdaniels.com> wrote:

>
>
> > 1. Does VB support variable variables,  ie using the value of a variable
> > as a variable name?
>
> Yes, using Eval.
>
> firstvar = "fish"
> secondvar = "wife"
> var = Eval(firstvar & secondvar) 'var = fishwife
>
> I think that's right, though it's been a while and my ASP's a bit rusty.




Err no.

put it into an ASP page and it will  not work, no error

E.g.

<%
firstvar = "fish"
secondvar = "wife"
var = Eval(firstvar & secondvar)
response.write var
%>

However you can do something like

<%
var = "Response.write ""Test"""
Execute Var
%>

But variable variables no well not in the same way PHP does.

e.g.

<?php
$a = 'hello';
$$a = 'world';
echo "$a ${$a}";
?>

> > 2. With a ASP/VB to Access via ADO connection setup, is it possible to
> > get the server to auto-truncate the input value of a field - so that if
> > a field is set up as say text / 50 characters long, and the input is
> > longer, it just truncates to 50 chars rather than throw an error?  Or do
> > I have to truncate separately before writing to the database?
>
> You can catch errors and hide them, or truncate data. Don't think you can
> do what you want and just add the first 50 chars without truncating before
> inserting.


I do it in the insert query.

--
David


More information about the BNMList mailing list
BNMList is hosted by Screenlists, a Screen-Play.net service