|
-
Apr 14th, 2000, 08:25 AM
#1
Thread Starter
Member
I am printing an array that can have up to 50 words. (not so much)
I want the pic box to display the entire array.
This program also lists the items alphabetically.
How do I go from:
picDisplay.print state(n)& " "
to printing the items so that they will not run out of the picbox?
-
Apr 14th, 2000, 08:55 AM
#2
Hyperactive Member
Why are you trying to display strings in a picture box?
wouldn't it be easier to put them into a listbox?
-
Apr 14th, 2000, 09:04 AM
#3
Thread Starter
Member
Working on a school assignment - this is the program
Dim state(1 To 50) As String
Dim Amt As Integer
Option Explicit
Private Sub cmdDisplay_Click()
Call DisplayArray
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdInsert_Click()
'insert state into ordered array and display states
Call AddState
Call DisplayArray
End Sub
Private Sub cmdRemove_Click()
'remove state from ordered array and display states
Call RemoveState
Call DisplayArray
End Sub
Private Sub Form_Load()
state(1) = "ALABAMA"
state(2) = "ARIZONA"
state(3) = "ILLINOIS"
state(4) = "INDIANA"
state(5) = "WYOMING"
Amt = 5
End Sub
Private Sub DisplayArray()
Dim n As Integer
'display all states in array
picDisplay.Cls
For n = 1 To Amt
picDisplay.Print state(n) & " ";
Next n
txtState.Text = ""
txtState.SetFocus
End Sub
Private Sub AddState()
Dim newState As String, n As Integer, i As Integer
'Insert state into ordered array
If Amt = UBound(state) Then
MsgBox "All states have been entered"
Else
newState = UCase(txtState.Text)
state(Amt + 1) = newState
n = 1
Do While state(n) < newState
n = n + 1
Loop
If (UCase(newState) = state(n)) And (n <= Amt) Then
MsgBox "State is already listed in array"
Else
For i = Amt To n Step -1
state(i + 1) = state(i)
Next i
state(n) = newState
Amt = Amt + 1
End If
End If
txtState.Text = ""
txtState.SetFocus
End Sub
Private Sub RemoveState()
Dim remState As String, n As Integer, i As Integer
'remove a state from the array
remState = UCase(txtState.Text)
n = 1
Do While (n < Amt) And (remState > state(n))
n = n + 1
Loop
If (Amt = 0) Or (remState <> state(n)) Then
MsgBox "state is not found in array"
Else
Amt = Amt + 1
For i = n To Amt
state(i) = state(i + 1)
Next i
End If
txtState.Text = ""
End Sub
-
Apr 14th, 2000, 02:06 PM
#4
Hyperactive Member
Try this on for size:
Code:
Private Sub DisplayArray()
Dim n As Integer
Dim tHeight As Long
Dim tWidth As Long
Dim temp As Long
Call Me.picDisplay.Cls
tHeight = 0
tWidth = 0
For n = 1 To Amt
tHeight = tHeight + Me.picDisplay.TextHeight(state(n)) + 30
temp = Me.picDisplay.TextWidth(state(n)) + 75
If (temp > tWidth) Then tWidth = temp
Next n
Me.picDisplay.Width = tWidth
Me.picDisplay.Height = tHeight
Me.picDisplay.AutoRedraw = True
For n = 1 To Amt
picDisplay.Print state(n)
Next n
Me.txtState.Text = ""
Call Me.txtState.SetFocus
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|