String array in a structure

  • Thread starter Thread starter OpticTygre
  • Start date Start date
O

OpticTygre

I have a structure:

Structure SSHConnection
Public EventLogErrors As Boolean
Public EventLogWarnings As Boolean
Public EventLogInformation As Boolean
Public Port As Integer
Public ListenAddress As String
Public MaxConnections As Integer
Public EncAES256 As Boolean
Public EncAES192 As Boolean
Public EncAES128 As Boolean
Public Enc3DES As Boolean
Public EncTwoFish As Boolean
Public EncBlowFish As Boolean
Public EncDES As Boolean
Public UserName As String
Public Password As String
Public EventLogUser As Boolean
Public EventLogUploads As Boolean
Public EventLogDownloads As Boolean
Public EventLogDir As Boolean
Public EventLogMod As Boolean
Public SFTPRootDir As String
Public HostIPAddresses() As String
End Structure

I also have an object defined as follows: Public SSHParams as New
SSHConnection

The last part, I'm declaring as an array of strings to hold a bunch of IP
addresses. I'm still a little sketchy with arrays, so I need some help on
how to set values. For example, if I want to clear all the contents of the
array, I'm choosing to use "Redim SSHParams.HostIPAddresses(0)" which seems
to work.

What doesn't work is when I try to add items into the array. Right now, I'm
trying to do the following in a separate Subroutine:

ReDim Preserve
SSHParams.HostIPAddresses(SSHParams.HostIPAddresses.GetUpperBound(0) + 1)
SSHParams.HostIPAddresses(SSHParams.HostIPAddresses.GetUpperBound(0) + 1) =
txtIPAddress.Text

And I'm sure this is totally wrong, as I am getting an "Object reference not
set to an instance of an object" exception. What's the right way of doing
something like this?
 
You set the size of the array to zero in your example, try this instead

Public Sub resetStrings(ByVal size As Integer)

ReDim HostIPAddresses(size)

End Sub


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
Back
Top