CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

【超难问题100分只给一个人】如何把把一字符转换成对应的变量名

楼主yangjunxx(时光)2003-11-02 11:58:11 在 Web 开发 / ASP 提问

stemp=123456  
   
  请问怎么才可以用   ddd="stemp"   的方法读出对应的变量stemp  
  问题点数:0、回复次数:10Top

1 楼yangjunxx(时光)回复于 2003-11-02 12:00:41 得分 0

顶一下,快哦,快哦Top

2 楼wangweinet777(石头)回复于 2003-11-02 12:05:12 得分 0

你是什么意思??  
  你直接取出变量的值不行吗?  
  Top

3 楼saucer(思归)回复于 2003-11-02 12:05:26 得分 0

look   into   Eval   Function  
   
  <%  
  stemp=123456  
  ddd="stemp"    
  Response.Write   (Eval(ddd))  
  %>Top

4 楼skyboy0720(曲终人散)回复于 2003-11-02 12:27:51 得分 0

TO:sacer  
   
  请问Eval是属于哪个语言的函数啊?哪有参考?!Top

5 楼carrotbill(萝卜)回复于 2003-11-02 12:34:54 得分 0

msdn  
   
  Eval   Function  
  Description  
   
  You   can   use   the   Eval   function   to   evaluate   an   expression   that   results   in   a   text   string   or   a   numeric   value.  
   
  You   can   construct   a   string   and   then   pass   it   to   the   Eval   function   as   if   the   string   were   an   actual   expression.   The   Eval   function   evaluates   the   string   expression   and   returns   its   value.   For   example,   Eval("1   +   1")   returns   2.  
   
  If   you   pass   to   the   Eval   function   a   string   that   contains   the   name   of   a   function,   the   Eval   function   returns   the   return   value   of   the   function.   For   example,   Eval("Chr$(65)")   returns   "A".  
   
  Syntax  
   
  Eval(stringexpr)  
   
  The   stringexpr   argument   is   an   expression   that   evaluates   to   an   alphanumeric   text   string.   For   example,   stringexpr   can   be   a   function   that   returns   a   string   or   a   numeric   value.   Or   it   can   be   a   reference   to   a   control   on   a   form.   The   stringexpr   argument   must   evaluate   to   a   string   or   numeric   value;   it   can't   evaluate   to   a   Microsoft   Access   object.  
   
  Note       If   you   are   passing   the   name   of   a   function   to   the   Eval   function,   you   must   include   parentheses   after   the   name   of   the   function   in   the   stringexpr   argument.   For   example:  
   
  Debug.Print   Eval("ShowNames()")   '   ShowNames   is   user-defined  
   
  '   function.  
   
  Debug.Print   Eval("StrComp(""Joe"",""joe"",   1)")  
   
  Debug.Print   Eval("Date()")  
   
  Remarks  
   
  You   can   use   the   Eval   function   in   a   calculated   control   on   a   form   or   report,   or   in   a   macro   or   module.   The   Eval   function   returns   a   Variant   that   is   either   a   string   or   a   numeric   type.  
   
  The   argument   stringexpr   must   be   an   expression   that   is   stored   in   a   string.   If   you   pass   to   the   Eval   function   a   string   that   doesn't   contain   a   numeric   expression   or   a   function   name   but   only   a   simple   text   string,   a   run-time   error   occurs.   For   example,   Eval("Smith")   results   in   an   error.  
   
  You   can   use   the   Eval   function   to   determine   the   value   stored   in   the   Value   property   of   a   control.   The   following   example   passes   a   string   containing   a   full   reference   to   a   control   to   the   Eval   function.   It   then   displays   the   current   value   of   the   control   in   a   dialog   box.  
   
  Dim   ctl   As   Control,   strCtl   As   String  
  Set   ctl   =   Forms!Employees!LastName  
  strCtl   =   "Forms!Employees!LastName"  
  MsgBox   ("The   current   value   of   "   &   ctl.Name   &   "   is   "   &   Eval(strCtl))  
  You   can   use   the   Eval   function   to   access   expression   operators   that   aren't   ordinarily   available   in   Visual   Basic.   For   example,   you   can't   use   the   SQL   operators   Between...And   or   In   directly   in   your   code,   but   you   can   use   them   in   an   expression   passed   to   the   Eval   function.  
   
  The   next   example   determines   whether   the   value   of   a   ShipRegion   control   on   an   Orders   form   is   one   of   several   specified   state   abbreviations.   If   the   field   contains   one   of   the   abbreviations,   intState   will   be   True   (–1).   Note   that   you   use   single   quotation   marks   (')   to   include   a   string   within   another   string.  
   
  Dim   intState   As   Integer  
  intState   =   Eval("Forms!Orders!ShipRegion   In   "   _  
          &   "('AK',   'CA',   'ID',   'WA',   'MT',   'NM',   'OR')")  
  See   Also  
   
  Choose   function,   IIf   function,   Switch   function.  
   
  Example  
   
  The   following   example   assumes   that   you   have   a   series   of   50   functions   defined   as   A1,   A2,   and   so   on.   This   example   uses   the   Eval   function   to   call   each   function   in   the   series.  
   
  Sub   CallSeries()  
          Dim   intI   As   Integer  
   
          For   intI   =   1   To   50  
                  Eval("A"   &   intI   &   "()")  
          Next   intI  
  End   Sub  
  The   next   example   triggers   a   Click   event   as   if   the   user   had   clicked   a   button   on   a   form.   If   the   value   of   the   button's   OnClick   property   begins   with   an   equal   sign   (=),   signifying   that   it   is   the   name   of   a   function,   the   Eval   function   calls   the   function,   which   is   equivalent   to   triggering   the   Click   event.   If   the   value   doesn't   begin   with   an   equal   sign,   then   the   value   must   name   a   macro.   The   RunMacro   method   of   the   DoCmd   object   runs   the   named   macro.  
   
  Dim   ctl   As   Control,   varTemp   As   Variant  
   
  Set   ctl   =   Forms!Contacts!HelpButton  
  If   (Left(ctl.OnClick,   1)   =   "=")   Then  
          varTemp   =   Eval(Mid(ctl.OnClick,2))  
  Else  
          DoCmd.RunMacro   ctl.OnClick  
  End   If  
  Top

6 楼myfc(狂草)回复于 2003-11-02 12:41:18 得分 0

Eval   是用来获得一条语句的值的Top

7 楼wolf004(色胚)回复于 2003-11-02 12:42:06 得分 0

计算给定表达式,并返回它的值  
   
  <SCRIPT   language=vbs>  
  msgbox   Eval(1+8)                   '返回   9  
  str1=2:str2=2  
  msgbox   Eval(str1=str2)       '返回True  
  </SCRIPT>  
  <SCRIPT>Top

8 楼dafei0320(我只知其然)回复于 2003-11-02 12:42:17 得分 0

Eval是计算一个表达式的值!  
  Top

9 楼dylwx(dylwx)回复于 2003-11-02 14:17:01 得分 0

javascript就能做到  
   
  具体方法你搜索一下innerHTML看看Top

10 楼supere(专心学习Dotnet)回复于 2003-11-02 17:07:59 得分 0

Eval是求一个表达式的值,并返回!  
  在js和vbs里都有这个函数Top

相关问题

  • 超简单,怎样将数字型变量转换为字符串变量。
  • 整型变量于字符串变量的转换问题?
  • 字符型变量与日期型变量的转换问题?
  • 字符变量和整型变量如何转换?
  • 如何将字符型变量转换成数字型变量。
  • 将整型变量(int)转换为字符型变量(char)
  • 如何将字符型变量转换为整形变量??????????
  • 关于字符串到变量和变量到字符串的转换
  • 怎样将整形变量转换为字符型变量输出?
  • 字符串变量怎样转换成对象变量,在线等待

关键词

  • debug
  • eval
  • stringexpr
  • 变量
  • evaluate
  • numeric
  • inti
  • stemp
  • example
  • expression

得分解答快速导航

  • 帖主:yangjunxx

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo