微软Visual Studio 2008基础教程.doc_第1页
微软Visual Studio 2008基础教程.doc_第2页
微软Visual Studio 2008基础教程.doc_第3页
微软Visual Studio 2008基础教程.doc_第4页
微软Visual Studio 2008基础教程.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

微软 Visual Studio 2008基础教程Visual Studio2008发布后,有大量的VB.net爱好者抛弃原来的Visual Studio2005平台转向现在流行的Visual Studio2008平台。但是Visual Studio2008有一个缺点就是需要比较高的硬件配置才能正常平稳的运行,所以到现在为止还有一部分人处于观望中,并没有转向这个平台。然而Visual Studio2008的一些新的功能以及优化性比先前版本有了很大的进步。本篇文章将主要介绍怎样利用VB.net去编写一个计算器程序,程序虽然不复杂,但是其中所运用的知识和代码非常具有代表性,在平时开发中也是经常需要用到的。希望对VB.net2008的初学者带来帮助。 打开 Visual Studio 2008。在文件 (File) 菜单上,单击新建项目 (New Project)。 在新建项目 (New Project) 对话框的模板 (Templates) 窗格中,单击 Windows 应用程序(Windows Application)。单击确定 (OK)。 在Form1窗体中添加一个TextBox1控件和19个Button按钮,详细属性设置请查看以下的表格。TextBox1数据显示框Button10Button2.Button3归零Button4无Button5Button61Button72Button83Button9+Button10-Button114Button125Button136Button14* Button15/Button167Button178Button189Button19ONButton20OFF 详细的界面请查看图1图1好了基本的界面已经设计好了,接下来我们来添加相应的代码了,首先进行必要的声明事件。Public Class Form1 Dim strdx() As String = 0, 0, 0 声明一个字符串,用以存取数值 Dim calcount1 As String = 0 Dim calcount2 As String = 0Dim strvalue As Boolean = False然后需要进入Button1.Click事件中.代码如下Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If strdx(0) = 0 Then TextBox1.Text = strdx(0) & . ElseIf strvalue = False Then strdx(0) = strdx(0) & 0 TextBox1.Text = strdx(0) & . Else strdx(0) = strdx(0) & 0 TextBox1.Text = strdx(0) End IfEnd Sub进入Button2.Click事件中.代码如下 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click strvalue = True strdx(0) = strdx(0) & . TextBox1.Text = strdx(0)End Sub进入Button3.Click事件中.代码如下Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click strdx(0) = 0 strdx(1) = 0 strdx(2) = 0 calcount1 = 0 calcount2 = 0 strvalue = False TextBox1.Text = 0.End Sub进入Button5.Click事件中.代码如下Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click If strdx(2) = 0 Then Select Case calcount1 Case + TextBox1.Text = Str(Val(strdx(1) + Val(strdx(0) Case - TextBox1.Text = Str(Val(strdx(1) - Val(strdx(0) Case * TextBox1.Text = Str(Val(strdx(1) * Val(strdx(0) Case / If strdx(0) = 0 Then TextBox1.Text = error! Else TextBox1.Text = Str(Val(strdx(1) / Val(strdx(0) End If End Select ElseIf calcount2 = * Then strdx(0) = Str(Val(strdx(0) * Val(strdx(2) Select Case calcount1 Case + TextBox1.Text = Str(Val(strdx(1) + Val(strdx(0) Case - TextBox1.Text = Str(Val(strdx(1) - Val(strdx(0) Case * TextBox1.Text = Str(Val(strdx(1) * Val(strdx(0) Case / If strdx(0) = 0 Then TextBox1.Text = error! Else TextBox1.Text = Str(Val(strdx(1) / Val(strdx(0) End If End Select Else : calcount2 = / strdx(0) = Str(Val(strdx(2) / Val(strdx(0) Select Case calcount1 Case + TextBox1.Text = Str(Val(strdx(1) + Val(strdx(0) Case - TextBox1.Text = Str(Val(strdx(1) - Val(strdx(0) Case * TextBox1.Text = Str(Val(strdx(1) * Val(strdx(0) Case / If strdx(0) = 0 Then TextBox1.Text = error! Else TextBox1.Text = Str(Val(strdx(1) / Val(strdx(0) End If End Select End If End Sub进入Button6.Click事件中.代码如下Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click If strdx(0) = 0 Then strdx(0) = 1 TextBox1.Text = strdx(0) & . ElseIf strvalue = False Then strdx(0) = strdx(0) & 1 TextBox1.Text = strdx(0) & . Else strdx(0) = strdx(0) & 1 TextBox1.Text = strdx(0) End If End Sub进入Button7.Click事件中.代码如下Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click If strdx(0) = 0 Then strdx(0) = 2 TextBox1.Text = strdx(0) & . ElseIf strvalue = False Then strdx(0) = strdx(0) & 2 TextBox1.Text = strdx(0) & . Else strdx(0) = strdx(0) & 2 TextBox1.Text = strdx(0) End IfEnd Sub进入Button8.Click事件中.代码如下Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click If strdx(0) = 0 Then strdx(0) = 3 TextBox1.Text = strdx(0) & . ElseIf strvalue = False Then strdx(0) = strdx(0) & 3 TextBox1.Text = strdx(0) & . Else strdx(0) = strdx(0) & 3 TextBox1.Text = strdx(0) End IfEnd Sub进入Button9.Click事件中.代码如下Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click If calcount1 = 0 Then calcount1 = + strdx(1) = strdx(0) strdx(0) = 0 Else : Select Case calcount1 Case + strdx(1) = Str(Val(strdx(0) + Val(strdx(1) strdx(0) = 0 calcount1 = + Case - strdx(1) = Str(Val(strdx(1) - Val(strdx(0) strdx(0) = 0 calcount1 = + Case * strdx(1) = Str(Val(strdx(0) * Val(strdx(1) strdx(0) = 0 calcount1 = + Case / strdx(1) = Str(Val(strdx(1) / Val(strdx(0) strdx(0) = 0 calcount1 = + End Select End IfEnd Sub进入Button10.Click事件中.代码如下Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click If calcount1 = 0 Then calcount1 = - strdx(1) = strdx(0) strdx(0) = 0 Else : Select Case calcount1 Case + strdx(1) = Str(Val(strdx(0) + Val(strdx(1) strdx(0) = 0 calcount1 = - Case - strdx(1) = Str(Val(strdx(1) - Val(strdx(0) strdx(0) = 0 calcount1 = - Case * strdx(1) = Str(Val(strdx(0) * Val(strdx(1) strdx(0) = 0 calcount1 = - Case / strdx(1) = Str(Val(strdx(1) / Val(strdx(0) strdx(0) = 0 calcount1 = - End Select End IfEnd Sub进入Button11.Click事件中.代码如下Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click If strdx(0) = 0 Then strdx(0) = 4 TextBox1.Text = strdx(0) & . ElseIf strvalue = False Then strdx(0) = strdx(0) & 4 TextBox1.Text = strdx(0) & . Else strdx(0) = strdx(0) & 4 TextBox1.Text = strdx(0) End IfEnd Sub进入Button12.Click事件中.代码如下Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click If strdx(0) = 0 Then strdx(0) = 5 TextBox1.Text = strdx(0) & . ElseIf strvalue = False Then strdx(0) = strdx(0) & 5 TextBox1.Text = strdx(0) & . Else strdx(0) = strdx(0) & 5 TextBox1.Text = strdx(0) End If End Sub进入Button13.Click事件中.代码如下Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click If strdx(0) = 0 Then strdx(0) = 6 TextBox1.Text = strdx(0) & . ElseIf strvalue = False Then strdx(0) = strdx(0) & 6 TextBox1.Text = strdx(0) & . Else strdx(0) = strdx(0) & 6 TextBox1.Text = strdx(0) End IfEnd Sub进入Button14.Click事件中.代码如下Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click If calcount1 = 0 Then calcount1 = * strdx(1) = strdx(0) strdx(0) = 0 Else : Select Case calcount1 Case + calcount2 = * strdx(2) = strdx(0) strdx(0) = 0 Case - calcount2 = * strdx(2) = strdx(0) strdx(0) = 0 Case * strdx(1) = Str(Val(strdx(0) * Val(strdx(1) strdx(0) = 0 calcount1 = * Case / strdx(1) = Str(Val(strdx(1) / Val(strdx(0) strdx(0) = 0 calcount1 = * End Select End IfEnd Sub进入Button15.Click事件中.代码如下 Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click If calcount1 = 0 Then calcount1 = / strdx(1) = strdx(0) strdx(0) = 0 Else : Select Case calcount1 Case + calcount2 = / strdx(2) = strdx(0) strdx(0) = 0 Case - calcount2 = / strdx(2) = strdx(0) strdx(0) = 0 Case * strdx(1) = Str(Val(strdx(0) * Val(strdx(1) strdx(0) = 0 calcount1 = / Case / strdx(1) = Str(Val(strdx(1) / Val(strdx(0) strdx(0) = 0 calcount1 = / End Select End IfEnd Sub进入Button16.Click事件中.代码如下Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click If strdx(0) = 0 Then strdx(0) = 7 TextBox1.Text = strdx(0) & . ElseIf strvalue = False Then strdx(0) = strdx(0) & 7 TextBox1.Text = strdx(0) & . Else strdx(0) = strdx(0) & 7 TextBox1.Text = strdx(0) End IfEnd Sub进入Button17.Click事件中.代码如下Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click If strdx(0) = 0 Then strdx(0) = 8 TextBox1.Text = strdx(0) & . ElseIf strvalue = False Then strdx(0) = s

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论