說(shuō)明:1.共有4個(gè)文本框其,其中三個(gè)是填入或輸出數(shù)據(jù)的(名稱(chēng)分別是:txta txtb txtc),剩下的那個(gè)是符號(hào)(txtd)2.共7個(gè)按鈕,4個(gè)是符號(hào)按鈕,一個(gè)計(jì)算,一個(gè)清零.這是我弄的程序”袖珍計(jì)算器”代碼也是自己編寫(xiě)的,代碼如下:通用聲明Dim j As Integer '定義j為整型
站在用戶(hù)的角度思考問(wèn)題,與客戶(hù)深入溝通,找到南城網(wǎng)站設(shè)計(jì)與南城網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶(hù)體驗(yàn)好的作品,建站類(lèi)型包括:成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名與空間、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋南城地區(qū)。
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里的內(nèi)容轉(zhuǎn)化為數(shù)值型,然后再賦給a
b = Val(txtb.Text) '將txtb.Text里的內(nèi)容轉(zhuǎn)化為數(shù)值型,然后再賦給b
If txtfuhao.Text = "+" Then '運(yùn)算過(guò)程
c = a + b '運(yùn)算過(guò)程
ElseIf txtfuhao.Text = "-" Then '運(yùn)算過(guò)程
c = a - b '運(yùn)算過(guò)程
ElseIf txtfuhao.Text = "÷" Then '運(yùn)算過(guò)程
c = a / b '運(yùn)算過(guò)程
ElseIf txtfuhao.Text = "×" Then '運(yùn)算過(guò)程
c = a * b '運(yùn)算過(guò)程
Else
j = MsgBox("您輸入的符號(hào)不正確", vbOKOnly, "錯(cuò)誤信息")
End If
txtc.Text = c '將運(yùn)算結(jié)果c輸出到文本框txtc中
End SubPrivate Sub Command6_Click()
txta.Text = "" '將空字符輸入到文本框內(nèi)(刷新)
txtb.Text = "" '將空字符輸入到文本框內(nèi)(刷新)
txtc.Text = "" '將空字符輸入到文本框內(nèi)(刷新)
txtfuhao.Text = "" '將空字符輸入到文本框內(nèi)(刷新)
End SubPrivate Sub Command7_Click()
End '結(jié)束程序
End SubPrivate Sub Form_Load()End Sub
大概的過(guò)程:
Imports System.Data
Imports System.Data.SqlClient
--------------
Dim a As New SqlDataAdapter
Dim con As SqlConnection
con = New SqlConnection( "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=.;Connect Timeout=30")
con.Open()
a.SelectCommand = New SqlCommand("select * from table where c=1", con)
a.UpdateCommand = New SqlCommand("update table set b=2 where c=1", con)
a.DeleteCommand = New SqlCommand("delete from table where c=1", con)
a.InsertCommand = New SqlCommand("insert into table values (1,2,3)", con)
a.SelectCommand.ExecuteNonQuery()
a.UpdateCommand.ExecuteNonQuery()
a.DeleteCommand.ExecuteNonQuery()
a.InsertCommand.ExecuteNonQuery()
con.Close()
a.Dispose()
'我不會(huì)計(jì)時(shí),因此下面代碼中沒(méi)有計(jì)時(shí)功能,要你自己去創(chuàng)建。
'Text1 As Label , Sui1 As Button , Sui2 As Button , Sui3 As Button , Fil1 As TextBox , Form1 As Form.
Public Class Form1
Private Sub Sui1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sui1.Click
Dim i As Random = New Random
Dim iText As String = ""
For mn As Int16 = 1 To 30
Dim si As Int16 = i.Next(0, 25)
If si = 0 Then
iText += "a"
ElseIf si = 1 Then
iText += "b"
ElseIf si = 2 Then
iText += "c"
ElseIf si = 3 Then
iText += "d"
ElseIf si = 4 Then
iText += "e"
ElseIf si = 5 Then
iText += "f"
ElseIf si = 6 Then
iText += "g"
ElseIf si = 7 Then
iText += "h"
ElseIf si = 8 Then
iText += "i"
ElseIf si = 9 Then
iText += "j"
ElseIf si = 10 Then
iText += "k"
ElseIf si = 11 Then
iText += "l"
ElseIf si = 12 Then
iText += "m"
ElseIf si = 13 Then
iText += "n"
ElseIf si = 14 Then
iText += "o"
ElseIf si = 15 Then
iText += "p"
ElseIf si = 16 Then
iText += "q"
ElseIf si = 17 Then
iText += "r"
ElseIf si = 18 Then
iText += "s"
ElseIf si = 19 Then
iText += "t"
ElseIf si = 20 Then
iText += "u"
ElseIf si = 21 Then
iText += "v"
ElseIf si = 22 Then
iText += "w"
ElseIf si = 23 Then
iText += "x"
ElseIf si = 24 Then
iText += "y"
ElseIf si = 25 Then
iText += "z"
End If
Next
Text1.Text = iText
Sui1.Enabled = False
Sui2.Enabled = True
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Fil1.Enabled = False
Sui2.Enabled = False
Sui3.Enabled = False
End Sub
Private Sub Sui2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sui2.Click
Fil1.Enabled = True
Sui3.Enabled = True
Fil1.Select()
End Sub
Private Sub Fil1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Fil1.TextChanged
If Fil1.Text.Count = Fil1.MaxLength Then
Fil1.Enabled = False
End If
End Sub
Private Sub Sui3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sui3.Click
Fil1.Enabled = False
Sui2.Enabled = False
Sui1.Enabled = True
Sui3.Enabled = False
'完成結(jié)果。
MsgBox("suidu:" 30)
End Sub
End Class
新建窗口,添加picture控件
利用line()方法畫(huà)線
line(開(kāi)始x坐標(biāo),開(kāi)始y坐標(biāo))-(結(jié)束x坐標(biāo),結(jié)束y坐標(biāo)),線的顏色,畫(huà)線的方式(默認(rèn)為線,B為矩形無(wú)填充,BF為填充的矩形)
For i = 1 To 16
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(255, 0, 0)
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(255, 0, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(0, 255, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(0, 255, 0)
Next i
如果要在窗口上畫(huà)也可以調(diào)用窗口的line方法即form.line()