在vb中如何引用数据库中的数据在pictruebox中通过LINE工具画出曲线!最好能给出代码!

在vb中如何引用数据库中的数据在pictruebox中通过LINE工具画出曲线!最好能给出代码!,第1张

以下给出用于在pictruebox以LINE语句画曲线代码:

Option Explicit'变量定义

Private gyhDate As String

Private chaxun11 As String

Private chaxun2 As String

Private zsl As Integer

Private wy_wy As Double

Private br_br As Double

Private quexian(9, 6000) As Variant'曲线变量

Private zsl1 As Integer

Private zsl11 As Integer

Private i As Integer

Private j As Integer

Private X As Integer

Private Y As Integer

Private fnt As Integer

Private txt As Variant

Private dd As Variant

'曲线显示文字函数

Public Function xp(colvb As Variant, xx As Variant, yy As Variant, txt As Variant)

Picture1ForeColor = colvb 'QBColor(14)

Picture1CurrentX = xx

Picture1CurrentY = yy

Picture1Print txt '

End Function

'数据查询

Private Sub DataGrid3_Click()

gyhDate = Adodc3Recordset(0)

chaxun1 = "select from jishijilu where gyh_riqi='" & gyhDate & "' order by shijian"

mdh = chaxun1

Adodc1ConnectionString = "Provider=MicrosoftJetOLEDB40;Data Source=C:\Ldgz\wdmdb;Persist Security Info=False"

Adodc1RecordSource = mdh

Adodc1Refresh

Adodc1RecordsetMoveLast

'Text1 = gyhDate

chaxun11 = "select from jishijilu where gyh_riqi='" & gyhDate & "'"

chaxun2 = " order by gyh_riqi,shijian"

mdh = chaxun11 & chaxun2

Adodc2ConnectionString = "Provider=MicrosoftJetOLEDB40;Data Source=C:\Ldgz\wdmdb;Persist Security Info=False"

Adodc2RecordSource = mdh

Adodc2Refresh

zsl = Adodc2RecordsetRecordCount

Text2 = zsl

Adodc2RecordsetMoveFirst

'将数据赋值于quexian(, )变量

For i = 0 To zsl - 1

quexian(0, i) = Adodc2Recordset(0)

For j = 2 To 9

quexian(j, i) = Adodc2Recordset(j)

Next j

Adodc2RecordsetMoveNext

Next i

cmdQuxianSetFocus

cmdRefhEnabled = True

cmdPrintEnabled = True

DataGrid3Visible = False

End Sub

'初始化

Private Sub Form_Load()

chaxun1 = "select gyh_riqi from jishijilu where gyh_riqi >'" & "" & "' group by gyh_riqi"

mdh = chaxun1

Adodc3ConnectionString = "Provider=MicrosoftJetOLEDB40;Data Source=C:\Ldgz\wdmdb;Persist Security Info=False"

Adodc3RecordSource = mdh

Adodc3Refresh

Adodc3RecordsetMoveLast

Picture2Height = 6765

Picture1Visible = False

cmdRefhEnabled = False

End Sub

'显示曲线代码

Private Sub cmdQuxian_Click()

'HScroll1Visible = True

DataGrid1Visible = False

Adodc1Visible = False

DataGrid3Visible = False

Adodc3Visible = False

Picture2Height = 7245

Picture1Visible = True

Picture1Cls

'坐标文字

colvb = vbWhite

xx = 100

yy = 150

txt = "℃"

wp = xp(colvb, xx, yy, txt)

yy = 350

txt = "100"

wp = xp(colvb, xx, yy, txt)

xx = 200

yy = 1850

txt = "50"

wp = xp(colvb, xx, yy, txt)

yy = 3350

xx = 300

txt = "0"

wp = xp(colvb, xx, yy, txt)

xx = 100

yy = 4850

txt = "-50"

wp = xp(colvb, xx, yy, txt)

xx = 0

yy = 6350

txt = "-100"

wp = xp(colvb, xx, yy, txt)

xx = 10800 + 100

yy = 150

txt = "℃"

wp = xp(colvb, xx, yy, txt)

yy = 350

txt = "100"

wp = xp(colvb, xx, yy, txt)

xx = 10800 + 200

yy = 1850

txt = "50"

wp = xp(colvb, xx, yy, txt)

yy = 3350

xx = 10800 + 300

txt = "0"

wp = xp(colvb, xx, yy, txt)

xx = 10800 + 100

yy = 4850

txt = "-50"

wp = xp(colvb, xx, yy, txt)

xx = 10800 + 0

yy = 6350

txt = "-100"

wp = xp(colvb, xx, yy, txt)

'真空坐标

colvb = vbRed

xx = 11400

yy = 150

txt = "Pa"

wp = xp(colvb, xx, yy, txt)

yy = 350

txt = "1000"

wp = xp(colvb, xx, yy, txt)

xx = 11500

yy = 1850

txt = "100"

wp = xp(colvb, xx, yy, txt)

yy = 3350

xx = 11600

txt = "10"

wp = xp(colvb, xx, yy, txt)

xx = 11700

yy = 4850

txt = "1"

wp = xp(colvb, xx, yy, txt)

xx = 11500

yy = 6350

txt = "01"

wp = xp(colvb, xx, yy, txt)

xx = 500

yy = 150

txt = "Pa"

wp = xp(colvb, xx, yy, txt)

yy = 350

txt = "1000"

wp = xp(colvb, xx, yy, txt)

yy = 150

xx = 2200

txt = "6hr"

wp = xp(colvb, xx, yy, txt)

xx = 4000

txt = "12hr"

wp = xp(colvb, xx, yy, txt)

xx = 5800

txt = "18hr"

wp = xp(colvb, xx, yy, txt)

xx = 7600

txt = "24hr"

wp = xp(colvb, xx, yy, txt)

xx = 9400

txt = "30hr"

wp = xp(colvb, xx, yy, txt)

xx = 13000

txt = "42hr"

wp = xp(colvb, xx, yy, txt)

xx = 14800

txt = "48hr"

wp = xp(colvb, xx, yy, txt)

xx = 16600

txt = "54hr"

wp = xp(colvb, xx, yy, txt)

xx = 18400

txt = "60hr"

wp = xp(colvb, xx, yy, txt)

xx = 20200

txt = "66hr"

wp = xp(colvb, xx, yy, txt)

xx = 22000

txt = "72hr"

wp = xp(colvb, xx, yy, txt)

xx = 23800

txt = "78hr"

wp = xp(colvb, xx, yy, txt)

xx = 25600

txt = "84hr"

wp = xp(colvb, xx, yy, txt)

xx = 600

yy = 1850

txt = "100"

wp = xp(colvb, xx, yy, txt)

yy = 3350

xx = 11600

txt = "10"

wp = xp(colvb, xx, yy, txt)

xx = 700

yy = 4850

txt = "1"

wp = xp(colvb, xx, yy, txt)

xx = 600

yy = 6350

txt = "01"

wp = xp(colvb, xx, yy, txt)

xx = 22100

yy = 350

txt = "1000"

wp = xp(colvb, xx, yy, txt)

yy = 1850

txt = " 100"

wp = xp(colvb, xx, yy, txt)

yy = 3350

txt = " 10"

wp = xp(colvb, xx, yy, txt)

yy = 4850

txt = " 1"

wp = xp(colvb, xx, yy, txt)

yy = 6350

txt = " 01"

wp = xp(colvb, xx, yy, txt)

'画格

Picture1ForeColor = vbWhite

Picture1Line (450, 700)-(500, 700)

Picture1Line (450, 1000)-(500, 1000)

Picture1Line (450, 1300)-(500, 1300)

Picture1Line (450, 1600)-(500, 1600)

Picture1ForeColor = vbRed

Picture1Line (500, 5667)-(550, 5667)

Picture1Line (500, 7333)-(550, 7333)

Picture1Line (500, 900)-(550, 900)

Picture1Line (500, 10667)-(550, 10667)

Picture1Line (500, 12333)-(550, 12333)

Picture1Line (500, 1400)-(550, 1400)

Picture1Line (500, 15667)-(550, 15667)

Picture1Line (500, 17333)-(550, 17333)

Picture1Line (500, 20667)-(550, 20667)

Picture1Line (500, 22333)-(550, 22333)

Picture1Line (500, 2400)-(550, 2400)

Picture1Line (500, 25667)-(550, 25667)

Picture1Line (500, 27333)-(550, 27333)

Picture1Line (500, 2900)-(550, 2900)

Picture1Line (500, 30667)-(550, 30667)

Picture1Line (500, 32333)-(550, 32333)

Picture1Line (500, 35667)-(550, 35667)

Picture1Line (500, 37333)-(550, 37333)

Picture1Line (500, 3900)-(550, 3900)

Picture1Line (500, 40667)-(550, 40667)

Picture1Line (500, 42333)-(550, 42333)

Picture1Line (500, 4400)-(550, 4400)

Picture1Line (500, 45667)-(550, 45667)

Picture1Line (500, 47333)-(550, 47333)

Picture1Line (500, 50667)-(550, 50667)

Picture1Line (500, 52333)-(550, 52333)

Picture1Line (500, 5400)-(550, 5400)

Picture1Line (500, 55667)-(550, 55667)

Picture1Line (500, 57333)-(550, 57333)

Picture1Line (500, 5900)-(550, 5900)

Picture1Line (500, 60667)-(550, 60667)

Picture1Line (500, 62333)-(550, 62333)

Picture1ForeColor = vbWhite

Picture1Line (450, 400)-(25700, 400)

Picture1Line (450, 1900)-(25700, 1900)

Picture1Line (450, 3400)-(25700, 3400)

Picture1Line (450, 4900)-(25700, 4900)

Picture1Line (450, 6400)-(25700, 6400)

Picture1Line (450, 2200)-(500, 2200)

Picture1Line (450, 2500)-(500, 2500)

Picture1Line (450, 2800)-(500, 2800)

Picture1Line (450, 3100)-(500, 3100)

Picture1Line (450, 3700)-(500, 3700)

Picture1Line (450, 4000)-(500, 4000)

Picture1Line (450, 4300)-(500, 4300)

Picture1Line (450, 4600)-(500, 4600)

Picture1Line (450, 5200)-(500, 5200)

Picture1Line (450, 5500)-(500, 5500)

Picture1Line (450, 5800)-(500, 5800)

Picture1Line (450, 6100)-(500, 6100)

Picture1Line (500, 400)-(500, 6400)

Picture1Line (500 + 0, 400)-(500 + 0, 6400)

Picture1Line (1400 + 0, 400)-(1400 + 0, 6400)

Picture1Line (2300 + 0, 400)-(2300 + 0, 6400)

Picture1Line (3200 + 0, 400)-(3200 + 0, 6400)

Picture1Line (4100 + 0, 400)-(4100 + 0, 6400)

Picture1Line (5000 + 0, 400)-(5000 + 0, 6400)

Picture1Line (5900 + 0, 400)-(5900 + 0, 6400)

Picture1Line (6800 + 0, 400)-(6800 + 0, 6400)

Picture1Line (7700 + 0, 400)-(7700 + 0, 6400)

Picture1Line (8600 + 0, 400)-(8600 + 0, 6400)

Picture1Line (9500 + 0, 400)-(9500 + 0, 6400)

Picture1Line (10400 + 0, 400)-(10400 + 0, 6400)

Picture1Line (11300, 400)-(11300, 6400)

Picture1Line (12200, 400)-(12200, 6400)

Picture1Line (13100, 400)-(13100, 6400)

Picture1Line (14000, 400)-(14000, 6400)

Picture1Line (14900, 400)-(14900, 6400)

Picture1Line (15800, 400)-(15800, 6400)

Picture1Line (16700, 400)-(16700, 6400)

Picture1Line (17600, 400)-(17600, 6400)

Picture1Line (18500, 400)-(18500, 6400)

Picture1Line (19400, 400)-(19400, 6400)

Picture1Line (20300, 400)-(20300, 6400)

Picture1Line (21200, 400)-(21200, 6400)

Picture1Line (22100, 400)-(22100, 6400)

Picture1Line (23000, 400)-(23000, 6400)

Picture1Line (23900, 400)-(23900, 6400)

Picture1Line (24800, 400)-(24800, 6400)

Picture1Line (25700, 400)-(25700, 6400)

'画曲线

For j = 0 To zsl - 1

Picture1Line (j 5 + 500, quexian(2, j) -30 + 3399)-(j 5 + 500, quexian(2, j) -30 + 3401), vbRed, BF

Picture1Line (j 5 + 500, quexian(3, j) -30 + 3399)-(j 5 + 500, quexian(3, j) -30 + 3401), QBColor(7), BF

Picture1Line (j 5 + 500, quexian(4, j) -30 + 3399)-(j 5 + 500, quexian(4, j) -30 + 3401), vbBlack, BF

Picture1Line (j 5 + 500, quexian(5, j) -30 + 3399)-(j 5 + 500, quexian(5, j) -30 + 3401), vbYellow, BF

Picture1Line (j 5 + 500, quexian(6, j) -30 + 3399)-(j 5 + 500, quexian(6, j) -30 + 3401), vbGreen, BF

'准对数处理

If quexian(8, j) < 1 Then

wy_wy = 0 + 1667

br_br = 55

ElseIf quexian(8, j) >= 1 And quexian(8, j) < 10 Then

wy_wy = -1500 + 1667

br_br = 55556

ElseIf quexian(8, j) >= 10 And quexian(8, j) < 100 Then

wy_wy = -3000 + 1667

br_br = 05555

ElseIf quexian(8, j) >= 100 And quexian(8, j) < 1000 Then

wy_wy = -4500 + 1667

br_br = 0055555

End If

Picture1Line (j 5 + 500, quexian(8, j) br_br -30 + wy_wy + 3395 + 3000)-(j 5 + 500, quexian(8, j) br_br -30 + wy_wy + 3405 + 3000), QBColor(11), BF

Next j

cmdExitSetFocus

End Sub

以上代码需根据你实际处理数据情况修改,祝你成功!

你好,如果要把mysql数据库里的数据写入网页,你需要有一个后台服务器,然后用php读取mysql的数据,再显示到网页上去,表格很简单,html 的 table 就可以搞定, 曲线图就要用到javascript 插件了。

图的右边都有解释的啊,比如第一个图,表示CPU占用率,出现小山峰,表示CPU占用率高,系统当然慢,再比如第二个图,深蓝颜色代表的user I/O,出现小山峰表示你自己的I/O比较高,这些图很直白的,看仔细就知道了,希望能帮到你。

以下是vb从数据库中提取每日对应的温度曲线图代码。

Private Sub Command1_Click()

Dim i   As Integer

Dim conn  As New ADODBConnection

Dim rs     As New ADODBRecordset

Set conn = New ADODBConnection

Set rs = New ADODBRecordset

connConnectionString = "Provider=MicrosoftJetOLEDB40;Data Source=" & AppPath & "\tepmdb"

connOpen

rsOpen "select    from  mrwdb", conn, adOpenKeyset, adLockOptimistic

'  Set MSChart1DataSource = rs

With MSChart1

'// 以线条方式显示

chartType = 3

'// 把刻录改为手工方式

PlotAxis(VtChAxisIdY)ValueScaleAuto = False

'// 设置最大值

PlotAxis(VtChAxisIdY)ValueScaleMaximum = 50

'// 设置最小值

PlotAxis(VtChAxisIdY)ValueScaleMinimum = 0

'// 设置每格为 1

PlotAxis(VtChAxisIdY)ValueScaleMinorDivision = 1

'// 增加测试数据

ColumnCount = 1

'//轴坐标标题

PlotAxis(VtChAxisIdX, 0)AxisTitle = "日期"

PlotAxis(VtChAxisIdY, 0)AxisTitle = "温度"

'//轴坐标标题字体大小的设置

PlotAxis(VtChAxisIdX, 0)AxisTitleVtFontSize = 15

PlotAxis(VtChAxisIdY, 0)AxisTitleVtFontSize = 25

'//设置图表标题

TitleText = "日期和温度对应折线图"

'// 将图表作为图例的背景。

ShowLegend = False

'// 标记每个点的值

For i = 1 To PlotSeriesCollectionCount

PlotSeriesCollection(i)DataPoints(-1)DataPointLabelLocationType = VtChLabelLocationTypeAbovePoint

Next

If rsRecordCount > 0 Then

rsMoveFirst

Else

Exit Sub

End If

For i = 0 To rsRecordCount - 1

RowCount = rsRecordCount

Row = i + 1

RowLabel = CStr(rs("日期"))

Data = rs("温度")

rsMoveNext

Next

End With

End Sub

最终调试效果图如下:

以上就是关于在vb中如何引用数据库中的数据在pictruebox中通过LINE工具画出曲线!最好能给出代码!全部的内容,包括:在vb中如何引用数据库中的数据在pictruebox中通过LINE工具画出曲线!最好能给出代码!、怎样在 html 网页中显示MySQL数据表,然后在网页中能将时间、温度等数据调用成曲线或者直接形成表格、Oracle数据库监控实例的曲线图都是什么意思啊等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9395994.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-27
下一篇 2023-04-27

发表评论

登录后才能评论

评论列表(0条)

保存