Article ID: 180624
Article Last Modified on 6/28/2004
Option Explicit
Const MAX_CONNECTIONS = 98
Private Sub Form_Load()
'Creates a grid composed of labels.
Dim i As Integer
Dim n As Integer
Dim j As Integer
Dim temptop As Integer
Dim templeft As Long
templeft = 120
temptop = 120
' Set initial properties of label used as template for dynamically
' created labels.
Label1(0).BorderStyle = 1
Label1(0).Caption = ""
Label1(0).Visible = False
Label1(0).Move 120, 120, 1200, 300
' Size form to handle array of MAX_CONNECTIONS labels and other
' controls.
Me.Height = (Label1(0).Height * 14) + (60 * 15) + 980
Me.Width = (Label1(0).Width * 7) + (60 * 8) + 200
Me.Caption = "DDE Connection Limit Test"
'Set initial properties of Command1.
Command1.Caption = "Number of DDE connections"
Command1.Move 1420, Me.Height - 920, 4800, 400
Command1.Default = True
'Set initial properties of Text1.
Text1.Text = ""
Text1.Move 120, Command1.Top, 1200, Command1.Height
'Two nested For loops create grid of labels.
For i = 1 To 14 'Outer loop moves down the form,
For j = 1 To 7 'inner loop moves across the form.
n = n + 1 'supplies you with array index.
Load Label1(n)
Label1(n).Visible = True
Label1(n).Top = temptop
Label1(n).Left = templeft
templeft = templeft + Label1(0).Width + 60
Next j
templeft = 120
temptop = temptop + Label1(0).Height + 60
Next i
Me.Show
Text1.SetFocus
End Sub
Private Sub Command1_Click()
Dim iValue As Integer
Dim i As Integer
'Get the value entered by the user.
iValue = Val(Text1)
'Test for invalid value.
If iValue < 1 Or iValue > MAX_CONNECTIONS Then
MsgBox "Enter a number between 1 and " & MAX_CONNECTIONS
Exit Sub
End If
'Remove any existing connections and reset all captions.
For i = 1 To MAX_CONNECTIONS
Label1(i).LinkMode = vbLinkNone
Label1(i).Caption = ""
Next i
'Start DDE conversations for the chosen number of labels.
For i = 1 To iValue
Label1(i).LinkTopic = "EXCEL|Book1.xls"
Label1(i).LinkItem = "R1C1"
Label1(i).LinkMode = vbLinkAutomatic
Next i
End Sub
Additional query words: IPF GPF Crash Dynamic Data Exchange DDE Link
Keywords: kbbug kbfix kbinterop KB180624