|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Hello!
I am using Visual Basic 6 and MS access 2000 as my database. I need to get all the data from the various fields to load into my textbox array. THis my code: Option Explicit 'General Declaration Dim n, m, i As Integer Dim WithEvents cnn As ADODB.Connection Dim WithEvents rst As ADODB.Recordset Private Sub cmdList_Click() Unload Me frmViewBear.Show End Sub Private Sub Form_Load() Dim cnnstr As String Set cnn = New ADODB.Connection Set rst = New ADODB.Recordset cnnstr = "Select * from Node" With cnn .Provider = "Microsoft.Jet.OLEDB.4.0" .ConnectionString = "Data Source=C:\My Documents\My Project\bearer.mdb" .Open End With With rst .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockOptimistic .Open cnnstr, cnn End With End Sub Private Sub cmdFind_Click() 'Find Button Dim sFind As String Dim f As ADODB.Field Dim counter, inc, posRec As Integer inc = -500 If txtBID.Text = "" Then MsgBox "Please Enter the correct bearer Id", vbInformation, "Error" txtBID.SetFocus Exit Sub End If sFind = Trim(txtBID.Text) rst.Find "Bearer_ID LIKE " & "'" & sFind & "*'" posRec = rst.AbsolutePosition If (posRec > adPosBOF) Then If (Not posRec = rst.BOF Or rst.EOF) Then 'if the fields are not null For Each f In rst.Fields If Not IsNull(f.Value) Then counter = counter + 1 'increment the counter End If Next For n = 0 To (counter - 2) 'Loop to load the correct number of images inc = inc + 2000 'and textboxes Load imgbox(imgbox.UBound + 1) 'Load imgbox() array With imgbox(imgbox.UBound) ' imgbox property .Picture = LoadPicture(App.Path & "\circle.gif") .Left = inc .Top = 2000 .Width = 700 .Height = 700 .Visible = True End With Load Text1(Text1.UBound + 1) 'load upper textboxes With Text1(Text1.UBound) 'Textboxes properties .Left = inc .Top = 650 .Width = 800 .Height = 500 .Visible = True ' .Text = f.Value End With Load Text2(Text2.UBound + 1) 'load lower textboxes With Text2(Text2.UBound) 'Textboxes properties .Left = inc .Top = 3200 .Width = 800 .Height = 500 .Visible = True End With 'If picturebox is too small, increase the width and make scrollbar 'visible If imgbox(imgbox.UBound).Left > picInner.ScaleWidth Then picInner.Width = imgbox(imgbox.UBound).Left + 2000 HBar.Visible = True End If Next End If Else MsgBox "No records Found", vbCritical, "No records" End If ' loadRecord ' to load the records into textboxes For i = 0 To (Text1.Count - 2) Text1(i).Text = "" Next i = 0 Do Until rst.EOF Text1(i).Text = rst("Node1") i = i + 1 rst.MoveNext Loop End Sub |
|
#2
|
|||
|
|||
|
Do you get an error?
|
|
#3
|
|||
|
|||
|
ya....
Runtime error 340 Control Array element 6 does not exist. |
|
#4
|
|||
|
|||
|
Your some data.Value maybe is null...so your text array num is littler than data.Value...
To modify: i = 0 Do Until rst.EOF if rst("Node1")<>"" then Text1(i).Text = rst("Node1") i = i + 1 endif rst.MoveNext Loop |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > how to load data into the textbox array? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|