您只要會(huì)操作單元格中的數(shù)據(jù)自然就會(huì)了如下:Public Class Form1 Dim conn As Data.OleDb.OleDbConnection
柘城網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營(yíng)維護(hù)。成都創(chuàng)新互聯(lián)公司從2013年創(chuàng)立到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)公司。
Dim da As Data.OleDb.OleDbDataAdapter
Dim ds As Data.DataSet Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DataGridView1.AllowUserToOrderColumns = False
conn = New OleDb.OleDbConnection( Provider=Microsoft.Jet.OleDb.4.0;Data Source=D:\data.mdb ) 假設(shè)表中有兩項(xiàng): price 和 quaty
conn.Open()
da = New OleDb.OleDbDataAdapter( SELECT * FROM 表1 , conn)
ds = New Data.DataSet
da.Fill(ds)
conn.Close()
DataGridView1.DataSource = ds.Tables(0)
DataGridView1.Columns.Add( sum , sum ) 加入一項(xiàng) sum
For i As Int32 = 0 To DataGridView1.Rows.Count - 1
DataGridView1.Rows(i).Cells(2).Value = DataGridView1.Rows(i).Cells(0).Value * DataGridView1.Rows(i).Cells(1).Value 把前兩項(xiàng)的數(shù)據(jù)相乘,放到第三項(xiàng)中
Next
End Sub End Class
窗體上放一個(gè)textbox 兩條line 一個(gè)label 代碼粘貼 運(yùn)行 即見效果
'*************************************************************************
'**工程名稱:平面座標(biāo)
'**說 明:小鳥工作室 版權(quán)所有2007 - 2008(C)1
'**創(chuàng) 建 人:秋色烽火
'**日 期:2007-12-18 14:08:15
'**版 本:V1.0.0
'*************************************************************************
Const DPITCH = 300 '點(diǎn)距
Dim WithEvents oControlx1 As Line
Dim WithEvents oControlx2 As Line
Dim WithEvents oControly1 As Line
Dim WithEvents oControly2 As Line
Dim WithEvents oControlShape As Shape
Dim WithEvents oControlPixinfo As Label
Dim DPCound%, PixID%, PixBackColor, dotx%, doty%
Private Sub Form_Load()
Me.Caption = "平面座標(biāo) - by 秋色烽火[小鳥工作室]"
Me.Height = 9300
Me.Width = 9300
Line1.X1 = 150
Line1.X2 = Me.Width - 150
Line1.Y1 = Me.Height / 2
Line1.Y2 = Line1.Y1
Line2.Y1 = 150
Line2.Y2 = Me.Height - 150
Line2.X1 = Me.Width / 2
Line2.X2 = Line2.X1
Label1.Width = 255
Label1.Height = 255
Label1.AutoSize = ture
Label1.BackStyle = 0
Label1.FontItalic = True
Label1.FontBold = True
Label1.FontSize = 10
Label1.ForeColor = HFF
Label1.Caption = "O"
Label1.Left = Me.Width / 2 + Label1.Width - 100
Label1.Top = Me.Height / 2 - Label1.Height
Text1.Text = ""
Call AddLine
Text1.ToolTipText = "請(qǐng)輸入整數(shù)座標(biāo)(x,y) 中間用英文逗號(hào)分隔~~~,雙擊文本框或回車開始標(biāo)注" vbCrLf " 右擊顯示幫助信息 " vbCrLf "輸入座標(biāo)請(qǐng)介乎于" DPCound \ 2 "至" -1 * DPCound \ 2 "之間~~"
PixID = 0
End Sub
Sub AddLine()
DPCound = (Me.Width - 300) / DPITCH - 2
For i = DPCound \ 2 + 1 To DPCound
Set oControlx1 = Controls.Add("VB.Line", "lineW" i, Me)
Set oControlx2 = Controls.Add("VB.Line", "lineW" DPCound \ 2 - (i - (DPCound \ 2 + 1)), Me)
Set oControly1 = Controls.Add("VB.Line", "lineH" i, Me)
Set oControly2 = Controls.Add("VB.Line", "lineH" DPCound \ 2 - (i - (DPCound \ 2 + 1)), Me)
With oControlx1
.Visible = True '顯示
.X1 = Me.Width / 2 + (i - DPCound \ 2) * DPITCH
.X2 = Me.Width / 2 + (i - DPCound \ 2) * DPITCH
.Y1 = Me.Height / 2 - 60
.Y2 = Me.Height / 2 + 60
End With
With oControlx2
.Visible = True '顯示
.X1 = Me.Width / 2 - (i - DPCound \ 2) * DPITCH
.X2 = Me.Width / 2 - (i - DPCound \ 2) * DPITCH
.Y1 = Me.Height / 2 - 60
.Y2 = Me.Height / 2 + 60
End With
With oControly1
.Visible = True '顯示
.Y1 = Me.Height / 2 + (i - DPCound \ 2) * DPITCH
.Y2 = Me.Height / 2 + (i - DPCound \ 2) * DPITCH
.X1 = Me.Width / 2 - 60
.X2 = Me.Width / 2 + 60
End With
With oControly2
.Visible = True '顯示
.Y1 = Me.Height / 2 - (i - DPCound \ 2) * DPITCH
.Y2 = Me.Height / 2 - (i - DPCound \ 2) * DPITCH
.X1 = Me.Width / 2 - 60
.X2 = Me.Width / 2 + 60
End With
Next
End Sub
Sub AddPix()
If InStr(Text1.Text, ",") 0 Then
If IsNumeric(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1)) And IsNumeric(Mid$(Text1.Text, InStr(Text1.Text, ",") + 1, Len(Text1.Text))) Then
If CInt(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1)) = DPCound \ 2 And CInt(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1)) = -1 * DPCound \ 2 Then
PixID = PixID + 1
Set oControlShape = Controls.Add("VB.Shape", "Pix" PixID, Me)
Set oControlPixinfo = Controls.Add("VB.Label", "Pixinfo" PixID, Me)
With oControlShape
.Visible = True '顯示
.Shape = 3
'.BorderColor = HFF
.BackColor = HFF 'RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255)) 'HFF
.BackStyle = 1
.BorderStyle = 0
.Width = 75
.Height = 75
.Left = Me.Width / 2 + CInt(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1)) * DPITCH
.Top = Me.Height / 2 - CInt(Mid$(Text1.Text, InStr(Text1.Text, ",") + 1, Len(Text1.Text))) * DPITCH
dotx = .Left
doty = .Top
PixBackColor = .BackColor
End With
With oControlPixinfo
.Visible = True '顯示
.BackStyle = 0
' .FontItalic = True
'.FontBold = True
.FontSize = 9
.ForeColor = HFF 'PixBackColor 'HFF
.Caption = "[" PixID "]" CStr(CInt(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1))) "," CInt(Mid$(Text1.Text, InStr(Text1.Text, ",") + 1, Len(Text1.Text)))
.Width = 1000
.Height = 255
.Left = dotx
.Top = doty - .Height
.AutoSize = ture
End With
Text1.Text = ""
Else
MsgBox "輸入座標(biāo)請(qǐng)介乎于" DPCound \ 2 "至" -1 * DPCound \ 2 "之間~~", , "錯(cuò)誤"
Text1.Text = ""
End If
Else
MsgBox "座標(biāo)請(qǐng)使用數(shù)字輸入", , "錯(cuò)誤"
Text1.Text = ""
End If
Else
MsgBox "輸入的座標(biāo)請(qǐng)使用英文逗號(hào) , 進(jìn)行分隔", , "錯(cuò)誤"
Text1.Text = ""
End If
End Sub
Sub init()
If PixID 0 Then
If MsgBox("確實(shí)要清空所有標(biāo)注點(diǎn)嗎?", vbOKCancel + vbInformation + vbDefaultButton2 + vbMsgBoxSetForeground + vbSystemModal, "信息!") = vbOK Then
For i = 1 To PixID
Controls.Remove "Pix" i
Controls.Remove "Pixinfo" i
Next
PixID = 0
End If
End If
End Sub
Private Sub Text1_DblClick()
Call AddPix
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Call AddPix
End If
End Sub
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
MsgBox "請(qǐng)輸入整數(shù)座標(biāo)(x,y) 中間用英文逗號(hào)分隔~~~,雙擊文本框或回車開始標(biāo)注" vbCrLf "輸入座標(biāo)請(qǐng)介乎于" DPCound \ 2 "至" -1 * DPCound \ 2 "之間~~" vbCrLf "中鍵清空所有創(chuàng)建的座標(biāo)", , "幫助"
End If
If Button = 4 Then
Call init
End If
End Sub
'好玩的東東
'****************************
'如果加上下面的就好羅
'定時(shí)設(shè)為500
'Dim a, b As Integer
'a = 14
'b = 14
'Private Sub Timer1_Timer()
'Text1.Text = a "," b
'a = a - 1
'b = b - 1
'Call Text1_KeyDown(13, 1)
'End Sub
行列循環(huán)查詢就可以了阿
假如?DataSet1是你的?DataSet,見下面的代碼
Dim?db?As?DataTable?=?DataSet1.Tables("表名")
Dim?c?As?Integer?=?db.Columns.Count?-?1
Dim?r?As?Integer?=?db.Rows.Count?-?1
For?i?=?0?To?r
For?j?=?0?To?c
If?db.Rows(r).Item(i)?=?"A"?Then
MsgBox("行是:"??i??"列是:"??j)
End?If
Next
Next
你的思路完全正確
Dim curpos As Integer
curpos = BindingSource1.Position
BindingSource1.Position = curpos
分享文章:vb.net快速定位 vbnet focus
網(wǎng)頁鏈接:http://m.newbst.com/article38/doihssp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、網(wǎng)站排名、網(wǎng)站制作、品牌網(wǎng)站設(shè)計(jì)、全網(wǎng)營(yíng)銷推廣、自適應(yīng)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)