重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
lblresult是一个label控件,确定你的设计界面加入了一个label控件并将其命名为lblresult
网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了桥西免费建站欢迎大家使用!
说明:1.共有4个文本框其,其中三个是填入或输出数据的(名称分别是:txta txtb txtc),剩下的那个是符号(txtd)2.共7个按钮,4个是符号按钮,一个计算,一个清零.这是我弄的程序”袖珍计算器”代码也是自己编写的,代码如下:通用声明Dim j As Integer '定义j为整型
Private Sub Text1_Change()End SubPrivate Sub Command1_Click()
txtfuhao.Text = "+" '将”+”显示到文本框txtfuhao.Text中
End SubPrivate Sub Command2_Click()
txtfuhao.Text = "-" ''将”-”显示到文本框txtfuhao.Text中
End SubPrivate Sub Command3_Click()
txtfuhao.Text = "×" '将”×”显示到文本框txtfuhao.Text中
End SubPrivate Sub Command4_Click()
txtfuhao.Text = "÷" 将”÷”'显示到文本框txtfuhao.Text中
End Sub
Private Sub Command5_Click()
Dim a, b, c As Integer
a = Val(txta.Text) '将txta.Text里的内容转化为数值型,然后再赋给a
b = Val(txtb.Text) '将txtb.Text里的内容转化为数值型,然后再赋给b
If txtfuhao.Text = "+" Then '运算过程
c = a + b '运算过程
ElseIf txtfuhao.Text = "-" Then '运算过程
c = a - b '运算过程
ElseIf txtfuhao.Text = "÷" Then '运算过程
c = a / b '运算过程
ElseIf txtfuhao.Text = "×" Then '运算过程
c = a * b '运算过程
Else
j = MsgBox("您输入的符号不正确", vbOKOnly, "错误信息")
End If
txtc.Text = c '将运算结果c输出到文本框txtc中
End SubPrivate Sub Command6_Click()
txta.Text = "" '将空字符输入到文本框内(刷新)
txtb.Text = "" '将空字符输入到文本框内(刷新)
txtc.Text = "" '将空字符输入到文本框内(刷新)
txtfuhao.Text = "" '将空字符输入到文本框内(刷新)
End SubPrivate Sub Command7_Click()
End '结束程序
End SubPrivate Sub Form_Load()End Sub
Dim MyClient As WebClient = New WebClient
Dim MyReader As New System.IO.StreamReader(MyClient.OpenRead(url), System.Text.Encoding.Default) '定义新的文件流并读取网页文件数据,url表示需要打开的网页地址
Dim longTxt As String = MyReader.ReadToEnd 'longtxt存储了网页的源码
MyReader.Close()
Dim url As String=" 网址"
Dim httpReq As System.Net.HttpWebRequest
Dim httpResp As System.Net.HttpWebResponse
Dim httpURL As New System.Uri(url)
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
httpReq.Method = "GET"
httpResp = CType(httpReq.GetResponse(), HttpWebResponse)
httpReq.KeepAlive = False ' 获取或设置一个值,该值指示是否与
Internet资源建立持久连接。
Dim reader As StreamReader = _
New StreamReader(httpResp.GetResponseStream,
System.Text.Encoding.GetEncoding(-0))
Dim respHTML As String = reader.ReadToEnd() 'respHTML就是网页源代码
下面这段代码,是我用来计算每个月存500元进银行,连续30年,最后连本带利能有多少钱。这里面涉及复利计算。界面中右边的文本框用来输出每一次计算的结果。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nianxian As Integer '年限变量
Dim dingcun As Integer '定存变量
Dim fuli_big As Long '大复利
Dim fuli_small As Long '小复利
Dim i As Integer '循环变量
Dim DATAstring As String '数据字符串
nianxian = Val(年限_TextBox.Text)
dingcun = Val(定存_TextBox.Text)
DATAstring = ""
For i = 1 To nianxian
fuli_small = dingcun * (1 + 0.1875)
dingcun = fuli_small
fuli_big = fuli_big + fuli_small
DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_big) + Chr(13) + Chr(10)
'DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_small) + Chr(13) + Chr(10)
Next
'fuli_big = fuli_small
TextBox1.Text = DATAstring
结果_TextBox.Text = Str(fuli_big) + "元"
End Sub