⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 code01.htm

📁 关于VB控件的学习和一些使用方法
💻 HTM
字号:
<HTML>
<head><title>洪恩在线 - VB的控件的学习</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no_cache">

<link rel="stylesheet" href="/pub/css/home.css">
<link rel="stylesheet" href="/pc/program/program.css">
<meta name="keywords" content="程序设计,编程入门,源码,源程序,源码讲解,TextBox控件,VB,教程,电脑,教育,电脑乐园,交互">
<script language="javascript">
<!--
function change(myform)
{
        var url="www.hongen.com/pc/program/index.htm";
        url=myform.select.options[myform.select.options.selectedIndex].value;
        top.location.href=url;
}
//-->
</script></head>
<body bgcolor="#FFFFFF">
<script language=javascript src=/pub/js/head.js></script>


<!--顶部结束--> <!--菜单1开始--> <!--菜单1结束--> <!--菜单2开始--> <!--菜单2结束--> 
<table width="760" height="20" border=0 cellspacing="0" cellpadding="0" align="center">
  <tr valign="middle" align="left"> 
    <td height=20 class="p1" width="297" bgcolor="#D3E7FF" align=center><div align="left">   <a href="/pc/program/index.htm" class=under>程序设计栏目首页</a></div></td>
    <td align=left class="p1" height="20" width="58" valign="top"><img src="/pc/program/img/leftnew-0.gif" width="52" height="20"></td>
    <td align="right" class="p1" height="20" width="405"><font color="#330099">当前位置:<a href="/default.htm" class="under">洪恩在线</a> 
      -&gt; <a href="/pc/index.htm" class="under">电脑乐园</a> -&gt; VB的控件的学习</font><img name="image2" src="/pc/img/blank.gif" width="1" height="1"> 
    </td>
  </tr>
</table>
<table width=760 border=0 align="center" cellspacing="0" cellpadding="0">
  <tr>
    <td height=15><img src="/pc/img/blank.gif" width="1" height="1" border=0></td>
  </tr>
</table>
<!-- 工具软件列表1开始 --> 
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center" height="909">
  <tr> 
    <th width="150" bgcolor="6082CF" align="center" height="910" valign="top">      <!-- 左边条开始 --> 
      <script language="Javascript" src="/pc/program/js/proleft.js"></script>
      <!-- 左边条结束 -->
      <br>
    </th>
    <td bgcolor="#000000" width="1" height="910"><img src="/pc/img/blank.gif" width="1" height="1"></td>
    <td valign="top" align="center"> <br>
      <table width="95%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td>&nbsp;</td>
          <td width="13" valign="middle"><img src="/pc/program/img/dot.gif" width="13" height="13"></td>
          <td class="p2" width="150" align="center" valign="middle"><font color="B85959"><b>编 程 入 门 </b></font></td>
          <td width="179"><img src="/pc/program/img/logo2.gif" width="179" height="52"></td>
        </tr>
      </table>
      <table width="95%" border="0" cellspacing="0" cellpadding="0" class="p2">
        <tr> 
          <td height="15" valign="bottom" class="p2">--VB的控件的学习--<b>文本框TEXTBOX的使用方法举例--</b></td>
          <td height="15" valign="bottom" class="p2"> 
            <div align="right" class="p1"><a href="/pc/program/codtutor/code0101/code01.htm">下一节</a></div>
          </td>
        </tr>
        <tr> 
          <td bgcolor="FF9700" height="1" ><img src="img/blank.gif" width="1" height="2"></td>
          <td bgcolor="FF9700" height="1" ><img src="img/blank.gif" width="1" height="2"></td>
        </tr>
</table>
      <table width="95%" border="0" cellspacing="0" cellpadding="0" class="p2" background="/pc/img/line.gif">
        <tr> 
          <td class="p2" height="120" colspan="4"> 
            <p align="left"><span class="p2" style="line-height:17pt"><br>
                文本框控件(TextBox)是VB中最常用的控件。它是显示和输入文本的容器,相当于一个文字编辑器,提供了所有基本的文字处理功能,例如文本的编辑等。在下面这个小程序中,我们能看到文本框控件(TextBox)的最基本的属性。</span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  为了学习方便,提供的源码已经作了详细的中文注释,看看源码框中的代码:</span></p>
            <div align="center"> 
              <p> 
                <textarea name="textfield" cols="80" rows="7" onMouseOver="this.focus()" onFocus="this.select()" readonly>Option Explicit
'--------------------------------------
'           TextBox的常用属性的例子
'--------------------------------------
'           洪恩在线 求知无限
'--------------------------------------
'------名称-------------作用------------
'       CmdClear        清除文本框内容按钮
'       TextAll         文本框
'       CmdOK           给窗体FormBack的TextAll文本框赋值
'       FormTextBox     主窗体
'--------------------------------------
'--------------------------------------
'————文本框名称————属性设置———
'
'       TextPassWord    PassWordChar为 *
'       TextResume      Multiline为Ture, ScrollBars为2 -Vertical
'       TextAll         Multiline为Ture, ScrollBars为2 -Vertical
'                       Appearance为0 - Flat
'--------------------------------------


Private Sub CmdClear_Click()

    '清除所有文本框中的内容
    TextID.Text = ""
    TextPassWord.Text = ""
    TextName.Text = ""
    TextMail.Text = ""
    TextResume.Text = ""
    
End Sub

Private Sub CmdOK_Click()
    '把FormTextBox文本框的Text及标签的Caption赋给
    '窗体FormBack中TextAll文本框的Text属性
    FormBack.TextAll.Text = LblID.Caption & "   " & TextID.Text _
                            & vbNewLine & _
                            LblPassWord.Caption & "   " & TextPassWord.Text _
                            & vbNewLine & _
                            LblName.Caption & "   " & TextName.Text _
                            & vbNewLine & _
                            LblMail.Caption & "   " & TextMail.Text _
                            & vbNewLine & _
                            LblResume.Caption & "   " _
                            & vbNewLine & TextResume.Text
                                
                                '其中vbNewline是使TextAll.Text换行显示
    Load FormBack               '载入窗体Formback
    FormBack.Show               '显示窗体Formback
    FormTxtBox.Visible = False '设置窗体FormtextBox不可见
        
End Sub

</textarea> </div>
                <br>
                (<a href="/pc/program/codtutor/zip/code0101.zip">源程序下载</a>)
              <p align="left"><span class="p2" style="line-height:17pt">  这个例子的两个窗体界面如下:</span></p> </td></tr><tr><td>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left"><img src="img/form01.gif" width="222" height="328" vspace="10" hspace="10"></td>
                <td align="right" valign="bottom"><img src="img/form02.gif" width="320" height="240" vspace="10" hspace="10"></td>
              </tr>
              <tr>
                <td align="center">
                  <p class="p2" style="line-height:17pt">
                  主窗体(FormTxtBox)</p></td>
                <td align="center"><p class="p2" style="line-height:17pt">窗体(FormBack)</p></td>
              </tr>
            </table>
          </td></tr><tr>
          <td> 
            <p class="p2" style="line-height:17pt"><br>
                我们首先新建一个标准的EXE工程。添加两个窗体,并把TextBox、Button、Label控件放置在窗体上。各文本框的名称如下表:<br>
            </p>
          </td></tr><tr>
          <td>
            <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#CCCCFF">
              <tr>
                <td> 
                  <p class="p2" style="line-height:17pt">文本框名称</p>
                </td>
                <td> 
                  <p class="p2" style="line-height:17pt">名称属性</p>
                </td>
                <td> 
                  <p class="p2" style="line-height:17pt">文本框名称</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt">名称属性</p>
                </td>
              </tr>
              <tr> 
                <td>
                  <p class="p2" style="line-height:17pt"> 会员编号文本框</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt"> TextID</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt"> 电子邮件文本框</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt"> TextMail</p>
                </td>
              </tr>
              <tr> 
                <td>
                  <p class="p2" style="line-height:17pt"> 密码文本框</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt"> TextPassWord</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt"> 个人介绍文本框</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt"> TextResume</p>
                </td>
              </tr>
              <tr> 
                <td>
                  <p class="p2" style="line-height:17pt"> 姓名文本框</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt"> TextName</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt">会员信息文本框</p>
                </td>
                <td>
                  <p class="p2" style="line-height:17pt"> TextAll</p>
                </td>
              </tr>
            </table>
          </td>
        </tr>
		<tr>
          <td>
            <p align="left"><span class="p2" style="line-height:17pt"><br>
                在属性窗口中将TextPassWord的PassWordChar属性设为*;</span><span class="p2" style="line-height:17pt">TextResume的Multiline属性设为Ture,ScrollBars属性设为2 
              -Vertical;TextAll文本框的Multiline属性设为为Ture, ScrollBars属性设为2 -Vertical,Appearance属性设为为0 
              - Flat。</span></p>
            <p align="left"><span class="p2" style="line-height:17pt">   下一步我们为FormTxtBox窗体中“确定”(CmdOK)和“清除”(CmdClear)按钮的Click事件中添加相应的程序。</span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  其中:</span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  TextID.Text 
              = "" 是把会员编号文本框中的内容清空,其它语句与此类似。</span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  FormBack.TextAll.Text 
              = LblID.Caption & " " & TextID.Text _ & vbNewLine & </span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  该语句设置FormBack窗体中TextAll文本框的文本。vbNewLine是换行显示标志。“ 
              _”是续行标志,当语句一行写不下时使用此标志,但要<font color="#FF6666">注意:</font>前面要加空格。 
              </span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  代码写好之后,我们就可以保存工程,然后按“Ctrl+F5”键,测试检验一下我们的程序了。<br>
              </span></p>
            </td>
        </tr>
        <tr> 
          <td bgcolor="FF9700" height="2" width="5%"><img src="/pc/img/blank.gif" width="1" height="2"></td>
        </tr>
      </table>
      
      <table width="95%" align="center" class="p1" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="16%"> 
            <div align="center"><a href="/pc/program/index.htm">程序设计首页</a></div>
          </td>
          <td width="16%"> 
            <div align="center"><a href="/pc/program/codtutor/index.htm" color="#009999">趣味程序首页</a></div>
          </td>
          <td width="41%"> 
            <div align="left">相关链接:   <a href="/pc/program/tutors/index.htm">看实例学VB</a></div>
          </td>
          <td width="16%"> 
            <div align="right"><a href="/pc/program/tutors/code0102/code01.htm">下一节</a></div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<!--底部开始--> 
<script language="Javascript" src="/pub/js/foot.js"></script>
<!--底部结束--></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -