Skip to content

VBMAN.Toast - Notification Message Object

Overview

VBMAN.Toast provides non-blocking notification message display functionality, similar to Toast notifications in modern operating systems. Supports 9 display positions, 4 state styles, 2 themes, suitable for scenarios where user notification is needed without interrupting operations.

Core Features

  • 9 Display Positions: Top-left, left-center, bottom-left, top-center, center, bottom-center, top-right, right-center, bottom-right
  • Chain Calling: Supports fluent chain API design
  • Auto Stacking: Non-center positions support automatic stacking display
  • State Styles: Info, Success, Warning, Error four visual states
  • Theme Switching: Supports Light/Dark themes
  • Tag Management: Supports managing specific Toasts by tag name
  • Event Notification: Provides count change and all-close events

Enum Types

EnumPos - Display Position

ConstantValueDescription
LeftTop10Top-left corner
LeftCenter12Left-center (centered, no stacking)
LeftBottom14Bottom-left corner
CenterTop20Top-center
Center22Center (centered, no stacking)
CenterBottom24Bottom-center
RightTop30Top-right corner
RightCenter32Right-center (centered, no stacking)
RightBottom34Bottom-right corner

EnumState - Message State

ConstantValueDescription
Info1Info (blue)
Success2Success (green)
Warning3Warning (yellow)
Danger4Error (red)

EnumTheme - Theme

ConstantValueDescription
Light1Light theme
Dark2Dark theme

Chain Calling Methods

Pos

Set display position, supports chain calling.

vb
Public Function Pos(p As EnumPos) As cToast

Example:

vb
' Display in top-right corner
VBMAN.Toast.Pos(RightTop).Show "Operation successful"

' Display in bottom-left corner
VBMAN.Toast.Pos(LeftBottom).Show "Download complete"

State

Set message state, affects visual style.

vb
Public Function State(s As EnumState) As cToast

Example:

vb
' Success notification
VBMAN.Toast.State(Success).Show "Save successful"

' Error notification
VBMAN.Toast.State(Danger).Show "Operation failed"

' Warning notification
VBMAN.Toast.State(Warning).Show "Please check"

Theme

Set theme.

vb
Public Function Theme(t As EnumTheme) As cToast

Example:

vb
' Dark theme
VBMAN.Toast.Theme(Dark).Show "Night mode notification"

' Light theme (default)
VBMAN.Toast.Theme(Light).Show "Normal notification"

InstIndex

Manually set stack index (only supports non-center positions).

vb
Public Function InstIndex(ByVal i As Long) As cToast

Description:

  • Center positions (Center, LeftCenter, RightCenter) don't support stacking
  • If this method is not called, system will automatically manage stack order

Example:

vb
' Specify stack at position 2
VBMAN.Toast.Pos(RightTop).InstIndex(1).Show "First"
VBMAN.Toast.Pos(RightTop).InstIndex(2).Show "Second"

Tag

Set Toast tag name for subsequent management.

vb
Public Function Tag(ByVal Name As String) As cToast

Description:

  • If tag is not set, system will auto-generate random tag
  • Toasts with same tag won't be created repeatedly

Example:

vb
' Set tag for later closing
VBMAN.Toast.Tag("upload_status").Show "Uploading..."

' Close Toast with specified tag
VBMAN.Toast.CloseMe "upload_status"

Show

Display Toast notification, end of chain call.

vb
Public Function Show(ByVal Content As String, Optional ByVal Delay As Long = 3000, Optional ByVal Title As String) As cToast

Parameters:

  • Content - Message content
  • Delay - Display duration (milliseconds, default 3000)
  • Title - Message title (optional, non-center positions show "Notification" by default)

Example:

vb
' Simple message
VBMAN.Toast.Show "Operation successful"

' With title and duration
VBMAN.Toast.Show "File save complete", 5000, "Success"

' Complete chain call
VBMAN.Toast _
    .Pos(RightTop) _
    .State(Success) _
    .Theme(Light) _
    .Tag("save_result") _
    .Show "File saved successfully!", 3000, "Complete"

Management Methods

CloseMe

Close Toast with specified tag.

vb
Public Function CloseMe(ByVal Name As String) As Boolean

Return Value: Whether successfully closed

Example:

vb
' Close Toast with specified tag
If VBMAN.Toast.CloseMe("upload_status") Then
    Debug.Print "Closed"
End If

CloseAll

Close all Toasts.

vb
Public Function CloseAll() As Boolean

Example:

vb
' Close all Toasts
VBMAN.Toast.CloseAll

' Call when form unloads
Private Sub Form_Unload(Cancel As Integer)
    VBMAN.Toast.CloseAll
End Sub

Exists

Check if Toast with specified tag exists.

vb
Public Function Exists(ByVal Name As String) As Boolean

Example:

vb
' Check if exists
If VBMAN.Toast.Exists("upload_status") Then
    Debug.Print "Upload status notification is showing"
End If

Statistics Properties

Count

Get total number of currently displayed Toasts.

vb
Public Property Get Count() As Long

Example:

vb
Debug.Print "Currently " & VBMAN.Toast.Count & " Toasts are showing"

ActiveKeys

Get collection of all active Toast tags.

vb
Public Property Get ActiveKeys() As Collection

Example:

vb
Dim keys As Collection
Set keys = VBMAN.Toast.ActiveKeys

Dim key As Variant
For Each key In keys
    Debug.Print "Active Toast: " & key
Next key

Events

OnToastCountChange

Triggered when Toast count changes.

vb
Public Event OnToastCountChange(ByVal TagName As String, ByVal IsDelete As Boolean, ByVal CurrentCount As Long)

Parameters:

  • TagName - Tag of changed Toast
  • IsDelete - True=deleted, False=added
  • CurrentCount - Current total count

OnCloseAll

Triggered when all Toasts are closed.

vb
Public Event OnCloseAll(ByVal closedCount As Long)

Parameters:

  • closedCount - Number of Toasts closed

Comprehensive Examples

Example 1: Notifications at Different Positions

vb
Private Sub ShowMultiPos()
    ' Top-right - Success notification
    VBMAN.Toast.Pos(RightTop).State(Success).Show "Save successful", 2000
    
    ' Top-left - Info notification
    VBMAN.Toast.Pos(LeftTop).State(Info).Show "New message", 3000
    
    ' Bottom-right - Warning notification
    VBMAN.Toast.Pos(RightBottom).State(Warning).Show "Disk space low", 5000
    
    ' Center - Error notification (centered display, no stacking)
    VBMAN.Toast.Pos(Center).State(Danger).Show "Operation failed!", 0, "Error"
End Sub

Example 2: Upload Progress Notification

vb
Private Sub UploadFile()
    Dim filePath As String
    filePath = "C:\data.zip"
    
    ' Show start upload notification
    VBMAN.Toast _
        .Pos(RightTop) _
        .State(Info) _
        .Tag("upload") _
        .Show "Uploading: " & filePath, 0, "Uploading"
    
    ' Simulate upload process
    Dim i As Integer
    For i = 0 To 100 Step 10
        ' Update progress...
        DoEvents
        Sleep 200
    Next i
    
    ' Close upload notification, show complete
    VBMAN.Toast.CloseMe "upload"
    VBMAN.Toast _
        .Pos(RightTop) _
        .State(Success) _
        .Show "Upload complete!", 3000, "Complete"
End Sub

Example 3: Batch Operation Notification

vb
Private Sub BatchProcess()
    Dim i As Integer
    Dim successCount As Integer
    Dim failCount As Integer
    
    ' Show start notification
    VBMAN.Toast _
        .Pos(CenterBottom) _
        .State(Info) _
        .Tag("batch") _
        .Show "Starting batch processing...", 0
    
    For i = 1 To 100
        If ProcessItem(i) Then
            successCount = successCount + 1
        Else
            failCount = failCount + 1
        End If
        
        ' Update notification every 25 processed
        If i Mod 25 = 0 Then
            VBMAN.Toast.CloseMe "batch"
            VBMAN.Toast _
                .Pos(CenterBottom) _
                .State(Info) _
                .Tag("batch") _
                .Show "Processed: " & i & "/100", 0
            DoEvents
        End If
    Next i
    
    ' Close progress notification
    VBMAN.Toast.CloseMe "batch"
    
    ' Show result
    If failCount = 0 Then
        VBMAN.Toast _
            .Pos(RightTop) _
            .State(Success) _
            .Show "All processed successfully!", 3000
    Else
        VBMAN.Toast _
            .Pos(RightTop) _
            .State(Warning) _
            .Show "Success: " & successCount & ", Failed: " & failCount, 5000
    End If
End Sub

Example 4: Auto Stack Effect

vb
Private Sub AutoStackDemo()
    Dim i As Integer
    
    ' Automatically stack and display multiple messages in top-right corner
    For i = 1 To 5
        VBMAN.Toast _
            .Pos(RightTop) _
            .State(Info) _
            .Show "Message " & i, 3000 + i * 1000
        
        Sleep 500
    Next i
End Sub

Example 5: Server-side Use (Avoid MsgBox Blocking)

vb
Public Sub HandleServerMessage(Data As cJson)
    If Common.IsServer = True Then
        ' Server-side avoids using MsgBox blocking, use Toast instead
        VBMAN.Toast _
            .Pos(RightTop) _
            .State(Info) _
            .Show Data("Content"), 60000, Data("Title")
        Exit Sub
    End If
End Sub

Example 6: Dark Theme Notification

vb
Private Sub DarkModeToast()
    ' Dark theme success notification
    VBMAN.Toast _
        .Pos(RightBottom) _
        .State(Success) _
        .Theme(Dark) _
        .Show "Night mode enabled", 2000
    
    ' Dark theme warning notification
    VBMAN.Toast _
        .Pos(LeftBottom) _
        .State(Warning) _
        .Theme(Dark) _
        .Show "Low battery", 5000, "System"
End Sub

Usage Suggestions

  1. Position Selection:

    • Normal notifications: Top-right (RightTop)
    • Important messages: Center (Center)
    • Auxiliary info: Bottom-center (CenterBottom)
  2. Center Position Limitations:

    • Center, LeftCenter, RightCenter don't support stacking
    • Only one centered Toast can be displayed at a time
  3. Tag Management:

    • Toasts that need to be closed later must have tags set
    • Toasts with same tag won't be created repeatedly
  4. Duration Settings:

    • Normal notifications: 2000-3000ms
    • Important messages: 5000ms or longer
    • Manual close needed: set to 0
  5. Resource Cleanup:

    • Call CloseAll when form unloads
    • Avoid Toast residue causing memory leaks

Notes

  • Toast is non-modal, won't block user operations
  • Display duration unit is milliseconds (1 second = 1000 milliseconds)
  • Supports using vbCrLf for multi-line content display
  • Centered position Toasts will overlay display, not stack
  • On Windows server may not display UI properly, recommended to use with logs

VB6 and LOGO copyright of Microsoft Corporation