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 ......
Visual Basic有着强大的数据库存取能力,不仅能够直接支持Ms Access数据库,而且通过其内部安装的ISAM驱动程序使它能间接支持FoxPro、dBASE等外来数据库。本文不仅从VB数据库体系结构的角度探索了VB对这些外来数据库的支持,还结合了一些实例具体阐述了使用数据库存取对象变量的方法实现这些外来数据库的新建、库结构修改、 ......
Dim ReturnValue, I
ReturnValue = Shell("Calc.EXE", 1) ' 运行计算器。
AppActivate ReturnValue ' 激活计算器。
For I = 1 To 100 ' 设置计数循环。
SendKeys I & "{+}", True ' 按下按键给计算器
Next I ' 将所有 I 值相加。
SendKeys "=", True ' 取得总合。
SendKeys "%{F4}", True ' 按 ALT+F4 关 ......