Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 17th, 2003, 04:31 AM
hamster84 hamster84 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Singapore
Posts: 21 hamster84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question how to load data into the textbox array?

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

Reply With Quote
  #2  
Old September 17th, 2003, 02:20 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,550 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 15 h 43 m 35 sec
Reputation Power: 640
Do you get an error?

Reply With Quote
  #3  
Old September 17th, 2003, 07:46 PM
hamster84 hamster84 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Singapore
Posts: 21 hamster84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ya....

Runtime error 340

Control Array element 6 does not exist.

Reply With Quote
  #4  
Old September 19th, 2003, 12:46 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via MSN to cleverpig
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > how to load data into the textbox array?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway