VBMAN Network Data Display Example
Overview
This example demonstrates how to use the VBMAN framework to implement real-time network data display, including data collection, transmission, parsing, and visualization features.
Project Structure
NetDataShow/
├── Form1.frm # Main form, contains data display interface
├── Form1.frx # Form resource file
├── NetDataShow.vbp # Project file
└── _pic/ # Image resource directory
Core Code Analysis
1. Data Display Form (Form1.frm)
vb
'Data display form
Private WithEvents NetClient As New cTcpClient
Private WithEvents Timer1 As New Timer
Private Sub Form_Load()
'Connect to data server
With NetClient
.Connect "127.0.0.1", 9000
End With
'Start periodic refresh
With Timer1
.Interval = 1000
.Enabled = True
End With
End Sub
'Data reception handling
Private Sub NetClient_OnDataArrival()
Dim data As String
data = NetClient.RecvText
'Parse data
ParseData data
'Update display
UpdateDisplay
End Sub
'Periodic refresh handling
Private Sub Timer1_Timer()
'Get latest data
NetClient.Send "GET_DATA"
End Sub
'Data parsing
Private Sub ParseData(data As String)
With VBMAN.Json
If .Decode(data) Then
'Parse temperature data
txtTemp.Text = .Item("temperature")
'Parse humidity data
txtHumidity.Text = .Item("humidity")
'Update trend chart
UpdateChart .Item("history")
End If
End With
End Sub
2. Chart Display Implementation
vb
'Update trend chart display
Private Sub UpdateChart(history As Object)
'Clear old data
Chart1.Clear
'Add new data points
For Each point In history
Chart1.AddPoint point("time"), point("value")
Next
'Refresh display
Chart1.Refresh
End Sub
'Custom display format
Private Sub FormatDisplay()
'Set value format
txtTemp.Format = "0.00 ℃"
txtHumidity.Format = "0.0 %"
'Set alarm thresholds
txtTemp.AlarmValue = 30
txtHumidity.AlarmValue = 85
'Configure chart style
With Chart1
.Title = "Temperature Trend"
.XLabel = "Time"
.YLabel = "Temperature(℃)"
.GridVisible = True
.Refresh
End With
End Sub
Feature Description
Data Collection Features
- Network communication
- Data parsing
- Real-time updates
- Periodic refresh
Data Display
- Numerical display
- Trend charts
- Alarm notifications
- Automatic refresh
User Interface
- Layout design
- Interactive control
- Display formatting
- Theme styling
Technical Points
- TCP communication implementation
- JSON data processing
- Chart control application
- Interface refresh mechanism
Use Cases
- Industrial monitoring
- Environmental monitoring
- Equipment status monitoring
- Data visualization
Extension Suggestions
- Add data recording
- Implement multi-channel display
- Add data analysis
- Support report export
- Optimize refresh mechanism