Original Poster
Posted 2007-04-21 05:16 · 中国 湖北 武汉 电信
中级用户
★★
scriptlover
Credits 328 Posts 131 Joined 2007-03-25 22:17 19-year member UID 82910 Gender Male
Status Offline
Floor 2
Posted 2007-04-21 05:32 · 中国 河北 保定 联通
银牌会员
★★★
Credits 1,513 Posts 554 Joined 2005-12-30 00:50 20-year member UID 48180 Gender Male
Status Offline
Floor 3
Posted 2007-04-21 05:36 · 中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212 Posts 2,478 Joined 2007-02-08 23:39 19-year member UID 79003 Gender Male
Status Offline
Floor 4
Posted 2007-04-21 05:38 · 中国 河北 保定 联通
银牌会员
★★★
Credits 1,513 Posts 554 Joined 2005-12-30 00:50 20-year member UID 48180 Gender Male
Status Offline
Floor 5
Posted 2007-04-21 06:41 · 中国 湖北 武汉 电信
中级用户
★★
scriptlover
Credits 328 Posts 131 Joined 2007-03-25 22:17 19-year member UID 82910 Gender Male
Status Offline
I tested brother baomaboy's code, but it still can't calculate the area of area2. Why is that???
Floor 6
Posted 2007-04-21 06:55 · 中国 湖北 武汉 电信
中级用户
★★
scriptlover
Credits 328 Posts 131 Joined 2007-03-25 22:17 19-year member UID 82910 Gender Male
Status Offline
I'm really learning VBS, and I've just started, so it's inevitable that I make mistakes. Please give me lots of guidance, slore.
Floor 7
Posted 2007-04-21 07:10 · 中国 湖北 武汉 电信
中级用户
★★
scriptlover
Credits 328 Posts 131 Joined 2007-03-25 22:17 19-year member UID 82910 Gender Male
Status Offline
Option Explicit
Dim r
Const PI=3.14
r=Inputbox("Please enter a num.")
Function area1()
area1=PI*r^2
Msgbox(area1)
Exit Function
PI=3.1415
Call area1()
area1=PI*r^2
Msgbox(area2)
Exit Function
End function
I modified it like this. There are no errors at all when running it, but I still can't get the values of area1 and area2. Please have a VBS expert explain!!
Floor 8
Posted 2007-04-21 07:35 · 中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212 Posts 2,478 Joined 2007-02-08 23:39 19-year member UID 79003 Gender Male
Status Offline
Your code is a complete mess. Could you first look at the proper format for defining custom functions?
Option Explicit
Dim r
r=Inputbox ("Please enter a num.")
area1
area2
Function area1()
area1=3.14*r*r
Msgbox area1
End Function
Function area2()
area2=3.1415*r*r
Msgbox area2
End Function
Floor 9
Posted 2007-04-21 11:09 · 中国 河北 保定 联通
银牌会员
★★★
Credits 1,513 Posts 554 Joined 2005-12-30 00:50 20-year member UID 48180 Gender Male
Status Offline
Originally posted by stornager at 2007-4-21 06:41:
I tested brother baomaboy's code, but it still can't calculate the area of area2. Why is that???
Hehe, it works fine here. Not sure whether it's your problem or your computer's problem.
Floor 10
Posted 2007-04-22 04:30 · 中国 湖北 武汉 电信
中级用户
★★
scriptlover
Credits 328 Posts 131 Joined 2007-03-25 22:17 19-year member UID 82910 Gender Male
Status Offline
Thanks for the guidance, solar. Your code is completely correct.
Floor 11
Posted 2007-05-30 09:22 · 中国 江苏 泰州 电信
初级用户
★
Credits 30 Posts 14 Joined 2006-01-10 16:39 20-year member UID 48757
Status Offline
area1=PI*r^2
Change it to area1=PI*(r^2) and try it! There seems to be a problem with operator precedence.
Floor 12
Posted 2007-05-30 11:17 · 中国 新疆 乌鲁木齐 电信
高级用户
★★★
Autowalk
Credits 845 Posts 375 Joined 2007-03-03 01:58 19-year member UID 80606 Gender Male
Status Offline
The format for defining the function is wrong
你好,脚本专家!
<a target=blank href=tencent://message/?uin=29654761&Site=www.111.com&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:29654761:5 alt="点击这里给我发消息"></a>
Forum Jump:
— Select —
站务公告 & 版主讨论
意见反馈 & 网友交流
DOS学习入门 & 精彩文章 (教学室)
DOS疑难解答 & 问题讨论 (解答室)
DOS启动盘 & LOGO技术 (启动盘室)
DOS批处理 & 脚本技术(批处理室)
DOS媒体世界 & 网络技术 (多媒体室)
DOS汉化世界 & 中文系统 (中文化室)
DOS开发编程 & 发展交流 (开发室)
DOS软件下载 & 游戏分享 (下载室)
GRUB4DOS、SYSLINUX及其它启动管理软件讨论专区
其它操作系统综合讨论区
WinPE、PowerShell及其它命令行系统专区
贴图灌水、文学娱乐专区
网络日志(Blog)
论坛回收站
├ 链接失效,待修正