c#程序 高手解决 急急!!

[复制链接]
查看11 | 回复4 | 2010-10-16 19:17:06 | 显示全部楼层 |阅读模式
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace datatime
{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void textBox1_TextChanged(object sender, EventArgs e)

{



}

private void btnQuery_Click(object sender, EventArgs e)

{

string strD = txtDay.Text;

string strM = txtMonth.Text;

string strY = txtYear.Text;



DateTime yy = new DateTime(Convert.ToInt32(strY),Convert.ToInt32(strM),Convert.ToInt32(strD));
txtValue.Text = yy.AddDays(1).ToString() ;
}

}
}
你看看 我都崩溃了 说我字符串格式问题

回复

使用道具 举报

千问 | 2010-10-16 19:17:06 | 显示全部楼层
你没有转换好时间类型请试试strY这些字符型后面加上.ToString()然后几个时间用“-”分开就可以表示,但是你一起转换就有问题了“ DateTime yy ” 这个参数没办法显示出来的哦年月日不能这样表示的哦更加不能这样转换:Convert.ToInt32
回复

使用道具 举报

千问 | 2010-10-16 19:17:06 | 显示全部楼层
代码没问题,可能是操作错误,建议再重做一个
回复

使用道具 举报

千问 | 2010-10-16 19:17:06 | 显示全部楼层
二楼的胡说,,,DateTime(Int32, Int32, Int32)将 DateTime 结构的新实例初始化为指定的年、月和日。 这个是没有问题的。。。你现在发出来的代码没有问题。。。你还没有其他的代码?或者可以HI我。。。我帮你看看。。。
回复

使用道具 举报

千问 | 2010-10-16 19:17:06 | 显示全部楼层
int strD = txtDay.Text;
int strM = txtMonth.Text;
int strY = txtYear.Text;
DateTime yy = new DateTime(strY,strM,strD);
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行