C#中调用VB中Inputbox功能
C#自己没有Inputbox这个类,但是Inputbox也蛮好用的,所以有两种方法可以使用
一:.间接调用vb中的Inputbox功能
1。在项目中添加对Microsoft.VisualBasic引用
2。在项目中添加命名空间Using Microsoft.VisualBasic;
3。以后就可以直接使用VB中的好多类库(爽啊……)
例如:textBox1.Text=Microsoft.VisualBasic.Interaction.InputBox(“提示性文字”, “对话框标题”, “默认值”, X坐标, Y坐标);
上面的 X坐标, Y坐标 可以取值为 –1 和 -1,表示屏幕中间位置显示。
二:还可以自己写一个InputBox()这个函数。动态生成一个FORM以及TEXTBOX和BUTTON等,确定好位置,返回用户输入的字符串。
public partial class InputBox : Form
{
private InputBox()
{
InitializeComponent();
}
public String getValue()
{
return textBox1.Text;
}
public static bool Show(String title,String inputTips,bool isPassword,ref String value)
{
InputBox ib = new InputBox();
if (title != null)
{
ib.Text = title;
}
相关文档:
内容提要摘要: The software of visual basic developed by Microsoft corporation is becoming one of the main develop tools at today。 As it's remarkable peculiarity, the Grid control has very great practical and active use。 This topic discusses how to use the grid control of VB to develop prati ......
C Sharp(C#)中如何删除文件(文件夹)
直接删除:
using System.IO;
...
string filePath = @"D:\...\xxx.xxx";
if (File.Exists(filePath))
{
File.Delete(filePath);
}
else
{
Console. ......
我们还可以采用一种更加简便的方
法来实现上述程序的功能。这就是将SqlConnection对象包含到using区块中,这样程序会自动调用Dispose()方法释放
SqlConnection对象所占用的系统资源,无需再使用SqlConnection对象的Close()方法。
范例程序代码如下:
public partial class _Default : System.Web.UI.Page
{
......
C#(C sharp)字符串和时间的相互转换。
一、DateTime –> string
时间类型转化成字符串类型,那是相当的简单,直接调用ToString()方法即可。如:
DateTime dt = DateTime.Now;
string dtStr = dt.ToString();
如果想对输出格式化,可以这么写:
dt.ToString("yyyy年MM月dd日"); ......
学习自定义控件的开发不仅可以使你开发出更灵活的系统更重要的是它可以使你加深对已有服务器控件的理解,得以更灵活的应用。
较之于asp,asp.net提供了更强大的功能,我比较喜欢它的代码分离技术和对诸如C#、VB.Net等强类型语言的使用,这是从开发者的角度来看
的,从用户的角度来看,会觉得它速度更快,运行更稳定 ......