im trying to get an IP address range into an array so that i can scan for example 192.168.1.1 to 192.168.1.12 the array that i created was in vb6 and even that one errored out because of the "." between each octet..
Im not using vb6 anymore, just express

array for IP address range
Raffaele Rialdi
Update on progress..
I added
ListBox1.Items.Add(currentAddress)
to the code and it seems that the output is only modifying the 3rd octet and outputing every loop to 255 on the 4th like so
staring ip address = 192.168.1.1
ending ip address = 192.168.8.14
scan begins/output
192.168.2.255
192.168.3.255
192.168.4.255
192.168.5.255
192.168.6.255
192.168.7.255
192.168.8.255
it needs to run all the way through from 1 to 255 the increment the 3rd octet and when the 3rd octet matches the 3rd octet from starting ip address, then the fourth should stop at 14 or whatever is listed..
nice job though gets me thinking on my feet
all and any replies are welcomed..Thanks
mthierauf
abdou_moujar
Hello. You should be able to add a range of ip addresses to a string array as follows:
Dim IpAddresses() As String = (New String() {"192.168.1.1", "192.168.1.2", "192.168.1.3"})
elixic
wow, alot cleaner then i expected..but none of the IPaddresses will be hardcodd, im guessing i can use a var for the addreses to scan
I need to be able to scan a range so, if the range was
192.168.1.1 to 192.168.3.14
i would need it to scan the ip address between that, also looking at the 3rd octet or second as well,so..that being said, it would scan upto 255 2 times and then upto 14 on the 3rd pass flagging the 3rd octet with each pass til it gets to 3..
I know this is a lil confusing..im more then confused..lol
Thank your for your time and knowlege sharing
John Hind
Hi...
I think the following will work for what you're needing...might need to tweak it a bit here and there. Hope this helps!
Dim ipAddresses As New ArrayList Dim endAddress As String = "192.168.3.14" Dim currentAddress As String = "" Dim firstOctet As Integer = 192 Dim secondOctet As Integer = 168 Dim thirdOctet As Integer = 1 Dim forthOctet As Integer = 1 Do ' set the current ip addresscurrentAddress =
String.Format("{0}.{1}.{2}.{3}", firstOctet, secondOctet, thirdOctet, forthOctet) ' add the current ip address to the arrayipAddresses.Add(currentAddress)
' increment the third and forth octetsforthOctet += 1
If forthOctet > 255 ThenforthOctet = 1
thirdOctet += 1
End If Loop Until currentAddress = endAddress Dim addressArray() As String = ipAddresses.ToArray(Type.GetType("System.String"))Gmorken
Hi. I don't mean to be insulting but I don't think you're using the code correctly. Here I've updated this to add all of the items to a listbox as I believe you're doing. The results in my code look like exactly what you're looking for (I think.). Note that you don't have to add each item to the listbox individually you can add a range of ip addresses in a single line. I apologize in advance if I've simply misunderstood you.
ListBox1.Items.Clear()
Dim ipAddresses As New ArrayList Dim endAddress As String = "192.168.3.14" Dim currentAddress As String = "" Dim firstOctet As Integer = 192 Dim secondOctet As Integer = 168 Dim thirdOctet As Integer = 1 Dim forthOctet As Integer = 1 Do ' set the current ip addresscurrentAddress =
String.Format("{0}.{1}.{2}.{3}", firstOctet, secondOctet, thirdOctet, forthOctet) ' add the current ip address to the arrayipAddresses.Add(currentAddress)
' increment the third and forth octetsforthOctet += 1
If forthOctet > 255 ThenforthOctet = 1
thirdOctet += 1
End If Loop Until currentAddress = endAddressListBox1.Items.AddRange(ipAddresses.ToArray(Type.GetType(
"System.String")))Here is the list it produced
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5
192.168.1.6
192.168.1.7
192.168.1.8
192.168.1.9
192.168.1.10
192.168.1.11
192.168.1.12
192.168.1.13
192.168.1.14
192.168.1.15
192.168.1.16
192.168.1.17
192.168.1.18
192.168.1.19
192.168.1.20
192.168.1.21
192.168.1.22
192.168.1.23
192.168.1.24
192.168.1.25
192.168.1.26
192.168.1.27
192.168.1.28
192.168.1.29
192.168.1.30
192.168.1.31
192.168.1.32
192.168.1.33
192.168.1.34
192.168.1.35
192.168.1.36
192.168.1.37
192.168.1.38
192.168.1.39
192.168.1.40
192.168.1.41
192.168.1.42
192.168.1.43
192.168.1.44
192.168.1.45
192.168.1.46
192.168.1.47
192.168.1.48
192.168.1.49
192.168.1.50
192.168.1.51
192.168.1.52
192.168.1.53
192.168.1.54
192.168.1.55
192.168.1.56
192.168.1.57
192.168.1.58
192.168.1.59
192.168.1.60
192.168.1.61
192.168.1.62
192.168.1.63
192.168.1.64
192.168.1.65
192.168.1.66
192.168.1.67
192.168.1.68
192.168.1.69
192.168.1.70
192.168.1.71
192.168.1.72
192.168.1.73
192.168.1.74
192.168.1.75
192.168.1.76
192.168.1.77
192.168.1.78
192.168.1.79
192.168.1.80
192.168.1.81
192.168.1.82
192.168.1.83
192.168.1.84
192.168.1.85
192.168.1.86
192.168.1.87
192.168.1.88
192.168.1.89
192.168.1.90
192.168.1.91
192.168.1.92
192.168.1.93
192.168.1.94
192.168.1.95
192.168.1.96
192.168.1.97
192.168.1.98
192.168.1.99
192.168.1.100
192.168.1.101
192.168.1.102
192.168.1.103
192.168.1.104
192.168.1.105
192.168.1.106
192.168.1.107
192.168.1.108
192.168.1.109
192.168.1.110
192.168.1.111
192.168.1.112
192.168.1.113
192.168.1.114
192.168.1.115
192.168.1.116
192.168.1.117
192.168.1.118
192.168.1.119
192.168.1.120
192.168.1.121
192.168.1.122
192.168.1.123
192.168.1.124
192.168.1.125
192.168.1.126
192.168.1.127
192.168.1.128
192.168.1.129
192.168.1.130
192.168.1.131
192.168.1.132
192.168.1.133
192.168.1.134
192.168.1.135
192.168.1.136
192.168.1.137
192.168.1.138
192.168.1.139
192.168.1.140
192.168.1.141
192.168.1.142
192.168.1.143
192.168.1.144
192.168.1.145
192.168.1.146
192.168.1.147
192.168.1.148
192.168.1.149
192.168.1.150
192.168.1.151
192.168.1.152
192.168.1.153
192.168.1.154
192.168.1.155
192.168.1.156
192.168.1.157
192.168.1.158
192.168.1.159
192.168.1.160
192.168.1.161
192.168.1.162
192.168.1.163
192.168.1.164
192.168.1.165
192.168.1.166
192.168.1.167
192.168.1.168
192.168.1.169
192.168.1.170
192.168.1.171
192.168.1.172
192.168.1.173
192.168.1.174
192.168.1.175
192.168.1.176
192.168.1.177
192.168.1.178
192.168.1.179
192.168.1.180
192.168.1.181
192.168.1.182
192.168.1.183
192.168.1.184
192.168.1.185
192.168.1.186
192.168.1.187
192.168.1.188
192.168.1.189
192.168.1.190
192.168.1.191
192.168.1.192
192.168.1.193
192.168.1.194
192.168.1.195
192.168.1.196
192.168.1.197
192.168.1.198
192.168.1.199
192.168.1.200
192.168.1.201
192.168.1.202
192.168.1.203
192.168.1.204
192.168.1.205
192.168.1.206
192.168.1.207
192.168.1.208
192.168.1.209
192.168.1.210
192.168.1.211
192.168.1.212
192.168.1.213
192.168.1.214
192.168.1.215
192.168.1.216
192.168.1.217
192.168.1.218
192.168.1.219
192.168.1.220
192.168.1.221
192.168.1.222
192.168.1.223
192.168.1.224
192.168.1.225
192.168.1.226
192.168.1.227
192.168.1.228
192.168.1.229
192.168.1.230
192.168.1.231
192.168.1.232
192.168.1.233
192.168.1.234
192.168.1.235
192.168.1.236
192.168.1.237
192.168.1.238
192.168.1.239
192.168.1.240
192.168.1.241
192.168.1.242
192.168.1.243
192.168.1.244
192.168.1.245
192.168.1.246
192.168.1.247
192.168.1.248
192.168.1.249
192.168.1.250
192.168.1.251
192.168.1.252
192.168.1.253
192.168.1.254
192.168.1.255
192.168.2.1
192.168.2.2
192.168.2.3
192.168.2.4
192.168.2.5
192.168.2.6
192.168.2.7
192.168.2.8
192.168.2.9
192.168.2.10
192.168.2.11
192.168.2.12
192.168.2.13
192.168.2.14
192.168.2.15
192.168.2.16
192.168.2.17
192.168.2.18
192.168.2.19
192.168.2.20
192.168.2.21
192.168.2.22
192.168.2.23
192.168.2.24
192.168.2.25
192.168.2.26
192.168.2.27
192.168.2.28
192.168.2.29
192.168.2.30
192.168.2.31
192.168.2.32
192.168.2.33
192.168.2.34
192.168.2.35
192.168.2.36
192.168.2.37
192.168.2.38
192.168.2.39
192.168.2.40
192.168.2.41
192.168.2.42
192.168.2.43
192.168.2.44
192.168.2.45
192.168.2.46
192.168.2.47
192.168.2.48
192.168.2.49
192.168.2.50
192.168.2.51
192.168.2.52
192.168.2.53
192.168.2.54
192.168.2.55
192.168.2.56
192.168.2.57
192.168.2.58
192.168.2.59
192.168.2.60
192.168.2.61
192.168.2.62
192.168.2.63
192.168.2.64
192.168.2.65
192.168.2.66
192.168.2.67
192.168.2.68
192.168.2.69
192.168.2.70
192.168.2.71
192.168.2.72
192.168.2.73
192.168.2.74
192.168.2.75
192.168.2.76
192.168.2.77
192.168.2.78
192.168.2.79
192.168.2.80
192.168.2.81
192.168.2.82
192.168.2.83
192.168.2.84
192.168.2.85
192.168.2.86
192.168.2.87
192.168.2.88
192.168.2.89
192.168.2.90
192.168.2.91
192.168.2.92
192.168.2.93
192.168.2.94
192.168.2.95
192.168.2.96
192.168.2.97
192.168.2.98
192.168.2.99
192.168.2.100
192.168.2.101
192.168.2.102
192.168.2.103
192.168.2.104
192.168.2.105
192.168.2.106
192.168.2.107
192.168.2.108
192.168.2.109
192.168.2.110
192.168.2.111
192.168.2.112
192.168.2.113
192.168.2.114
192.168.2.115
192.168.2.116
192.168.2.117
192.168.2.118
192.168.2.119
192.168.2.120
192.168.2.121
192.168.2.122
192.168.2.123
192.168.2.124
192.168.2.125
192.168.2.126
192.168.2.127
192.168.2.128
192.168.2.129
192.168.2.130
192.168.2.131
192.168.2.132
192.168.2.133
192.168.2.134
192.168.2.135
192.168.2.136
192.168.2.137
192.168.2.138
192.168.2.139
192.168.2.140
192.168.2.141
192.168.2.142
192.168.2.143
192.168.2.144
192.168.2.145
192.168.2.146
192.168.2.147
192.168.2.148
192.168.2.149
192.168.2.150
192.168.2.151
192.168.2.152
192.168.2.153
192.168.2.154
192.168.2.155
192.168.2.156
192.168.2.157
192.168.2.158
192.168.2.159
192.168.2.160
192.168.2.161
192.168.2.162
192.168.2.163
192.168.2.164
192.168.2.165
192.168.2.166
192.168.2.167
192.168.2.168
192.168.2.169
192.168.2.170
192.168.2.171
192.168.2.172
192.168.2.173
192.168.2.174
192.168.2.175
192.168.2.176
192.168.2.177
192.168.2.178
192.168.2.179
192.168.2.180
192.168.2.181
192.168.2.182
192.168.2.183
192.168.2.184
192.168.2.185
192.168.2.186
192.168.2.187
192.168.2.188
192.168.2.189
192.168.2.190
192.168.2.191
192.168.2.192
192.168.2.193
192.168.2.194
192.168.2.195
192.168.2.196
192.168.2.197
192.168.2.198
192.168.2.199
192.168.2.200
192.168.2.201
192.168.2.202
192.168.2.203
192.168.2.204
192.168.2.205
192.168.2.206
192.168.2.207
192.168.2.208
192.168.2.209
192.168.2.210
192.168.2.211
192.168.2.212
192.168.2.213
192.168.2.214
192.168.2.215
192.168.2.216
192.168.2.217
192.168.2.218
192.168.2.219
192.168.2.220
192.168.2.221
192.168.2.222
192.168.2.223
192.168.2.224
192.168.2.225
192.168.2.226
192.168.2.227
192.168.2.228
192.168.2.229
192.168.2.230
192.168.2.231
192.168.2.232
192.168.2.233
192.168.2.234
192.168.2.235
192.168.2.236
192.168.2.237
192.168.2.238
192.168.2.239
192.168.2.240
192.168.2.241
192.168.2.242
192.168.2.243
192.168.2.244
192.168.2.245
192.168.2.246
192.168.2.247
192.168.2.248
192.168.2.249
192.168.2.250
192.168.2.251
192.168.2.252
192.168.2.253
192.168.2.254
192.168.2.255
192.168.3.1
192.168.3.2
192.168.3.3
192.168.3.4
192.168.3.5
192.168.3.6
192.168.3.7
192.168.3.8
192.168.3.9
192.168.3.10
192.168.3.11
192.168.3.12
192.168.3.13
192.168.3.14