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. ......
C#代码与javaScript函数的相互调用
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click ......
C#(C sharp)字符串和时间的相互转换。
一、DateTime –> string
时间类型转化成字符串类型,那是相当的简单,直接调用ToString()方法即可。如:
DateTime dt = DateTime.Now;
string dtStr = dt.ToString();
如果想对输出格式化,可以这么写:
dt.ToString("yyyy年MM月dd日"); ......