vb.netif事件的简单介绍

asp.net时间判断的问题System.DateTime currentTime=new System.DateTime();
string str="";
int h=currentTime.Hour;
if(h12)
{
str="下午";
}
else
{
str="上午";
}
1、DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
int 年=currentTime.Year;
1.3 取当前月
int 月=currentTime.Month;
1.4 取当前日
int 日=currentTime.Day;
1.5 取当前时
int 时=currentTime.Hour;
1.6 取当前分
int 分=currentTime.Minute;
1.7 取当前秒
int 秒=currentTime.Second;
1.8 取当前毫秒
int 毫秒=currentTime.Millisecond;
【vb.netif事件的简单介绍】(变量可用中文)
1.9 取中文日期显示——年月日时分
string strY=currentTime.ToString("f"); //不显示秒
1.10 取中文日期显示_年月
string strYM=currentTime.ToString("y");
1.11 取中文日期显示_月日
string strMD=currentTime.ToString("m");
1.12 取中文年月日
string strYMD=currentTime.ToString("D");
1.13 取当前时分,格式为:14:24
string strT=currentTime.ToString("t");
1.14 取当前时间,格式为:2003-09-23T14:46:48
string strT=currentTime.ToString("s");
1.15 取当前时间,格式为:2003-09-23 14:48:30Z
string strT=currentTime.ToString("u");
1.16 取当前时间 , 格式为:2003-09-23 14:48
string strT=currentTime.ToString("g");
1.17 取当前时间 , 格式为:Tue, 23 Sep 2003 14:52:40 GMT
string strT=currentTime.ToString("r");
1.18获得当前时间 n 天后的日期时间
DateTime newDay = DateTime.Now.AddDays(100);
还是关于VB循环语句的问题上次有个朋友提过类似问题vb.netif事件 , 结合MSDN上vb.netif事件的说法,vb.netif事件我的理解是这样,循环开始时会建立一个循环条件,循环条件在循环过程中不会被改变 , 如果step是正数 , 循环条件应为循环变量(计数器)小于等于计数器的终值,注意这里,MSDN中从未将终值描述成为变量 , 而对于计数器才描述其为变量,举例说明vb.netif事件:
e=10
for i=1 to e
确定后的循环条件应为i=10 , i是变量 , 可以改变,i=10这个条件本身不会改变
所以循环体中修改i会改变循环的次数,而修改e不会,因为e并不在循环条件中
i=1
加这样一句,循环将永远进行不会停止
i=11
加这样一句,则运行到next后自动退出循环
另外注意一点,循环次数总是比你想像的要多一次,只不过最后一次循环只对循环条件进行比对,由于不满足循环条件而自动退出了循环,所以最后一次循环并未执行循环体的代码段
举例说明:
for i=1 to 10
当循环结束时,i不可能等于10,因为step为正数,循环条件应为i=10,所以i=10时是满足循环条件的,再循环一次 , 计数器i被加上步长(默认为1)之后成为11,再与循环条件进行比对,发现不满足i=10的循环条件 , 这才退出循环
关于vb.netif事件和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读