China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-08 15:19
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] VBS outputting half of a number View 851 Replies 8
Original Poster Posted 2008-05-12 11:02 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
dim h
h=1
h=h/2
msgbox(h)


Very strange, it shows .5 instead of 0.5
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 2 Posted 2008-05-12 11:06 ·  中国 江苏 苏州 吴江区 电信
银牌会员
★★★
Credits 1,608
Posts 780
Joined 2007-10-07 10:19
18-year member
UID 99089
Gender Male
Status Offline
In ordinary programs, if the integer part is 0 it can usually be omitted; it doesn't affect the calculation.
Floor 3 Posted 2008-05-12 11:08 ·  中国 上海 浦东新区 电信
中级用户
★★
Credits 484
Posts 250
Joined 2007-06-05 23:33
19-year member
UID 90372
Gender Male
Status Offline
I'm still not familiar with vbs, but as far as I know, when the integer part is 0, omitting it is a common way of writing it.
(Even the function calculators we use ourselves can directly use .x to input data.)
Floor 4 Posted 2008-05-12 11:10 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
So to display 0.5, it has to be like this:
dim h
h=1
h=h/2
msgbox("0"&h)
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 5 Posted 2008-05-12 13:22 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
jmz573515 +3 2008-05-14 08:09
Floor 6 Posted 2008-05-12 14:37 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
& just mechanically concatenates them together, so that's how it is....
dim h
h=1
h=h/2
msgbox(0&h)
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 7 Posted 2008-05-14 08:10 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
Floor 8 Posted 2008-05-14 11:52 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
Originally posted by jmz573515 at 2008-5-14 08:10 AM:
msgbox FormatNumber(1/2,1,-1)

(1/2,1,-1)

Why add 1 and -1 after it?
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 9 Posted 2008-05-14 12:15 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Look at the parameters of formatnumber...
Forum Jump: