Deleting Spaces, Putting each line into textbox

Butcher1993
10-13-2009, 03:36 PM
OK, SO i have this program that outputs all the servers on a specific game. It outputs it to a text file. HOWEVER, There is a lot of annoying spaces. This is kind of hard to explain, so ill try to explain it. This is what The text file looks like.

173.81.220.139 2302
70.26.235.69 2302
24.26.119.209 2302
99.244.109.8 2302
190.234.169.198 27667
189.143.252.124 2302
189.148.109.184 2302
220.106.200.28 53311
216.165.236.137 2302
65.12.248.94 2302
124.45.123.17 41441
189.143.252.124 50745
84.30.139.238 2302
76.30.11.219 2302
200.106.34.224 10580
201.211.7.78 2302
131.193.195.171 2302
98.208.217.4 2301
69.116.167.105 2302
124.45.123.17 47337
74.98.230.118 2302
75.74.93.241 2302
68.198.172.217 2302
74.174.178.3 35094
124.45.123.17 53434
41.248.215.87 2302
124.45.123.17 43333
74.220.166.108 2302
88.222.185.158 2302
190.84.10.60 2302
98.27.4.236 2302
99.36.34.86 2302
187.47.81.218 2302
174.48.246.228 63983
76.179.169.160 2302
24.7.253.125 2302
66.99.228.134 19437
124.45.123.17 49339
166.127.145.158 2302
190.159.82.229 60282
24.86.137.206 2302
89.229.49.196 2302
70.226.226.99 2302
88.8.209.149 2302
201.211.12.56 2302
68.190.45.152 2302
189.132.198.166 2302
71.231.161.196 2302
24.189.104.244 2302
70.241.67.29 2302
68.36.154.208 2302
174.101.179.3 2302
24.57.37.32 2302
190.144.118.179 2302
190.153.1.108 2302
24.78.47.171 2302
77.160.226.145 53091
76.185.255.23 2302
60.240.173.36 64216
123.211.165.239 49170
68.73.53.72 2302
99.233.147.22 2302
208.66.39.40 2302
98.196.13.20 2302
174.48.100.105 2302
124.45.123.17 42442
72.65.40.160 50872
189.142.61.152 2302
76.252.224.218 2302
187.137.44.195 49274
84.84.189.182 22780
189.188.190.168 2302
99.227.120.207 2302
75.185.82.50 60002
24.37.84.17 2767
76.101.8.37 2302
65.3.161.164 33321
71.115.153.77 50994
60.240.173.36 61200
82.47.74.249 5402
201.245.252.111 2302
88.76.115.72 2302
189.194.103.233 2302
70.79.160.135 2302
69.249.40.120 2302
96.239.153.86 2302
70.145.216.205 2302
199.126.131.17 61083
201.250.27.28 2302
75.121.227.102 50028
174.103.116.3 2302
190.200.115.11 62415
71.237.60.170 2302
75.152.70.14 2302
71.158.169.144 2302
86.100.89.69 62175
65.10.1.144 2302
83.119.150.130 2302
84.46.92.82 2302
99.247.253.48 2302
80.2.74.48 2302
69.250.32.247 2302
124.45.123.17 48338
76.234.122.190 2302
200.25.249.3 8046
124.45.123.17 46446
24.37.84.17 2302
72.187.138.153 2302
81.84.203.54 2302
81.226.56.81 63351
69.109.209.244 2302
97.102.67.38 2302
174.112.96.215 61175
208.62.1.31 2302
94.215.244.196 2302
208.62.0.67 2302
24.237.251.96 2304
98.163.93.55 60130
60.240.173.36 61204
124.45.123.17 46336
24.150.147.192 63887
68.35.42.211 2302
189.161.229.34 2302
68.238.216.149 50497
76.30.203.19 2302
189.130.116.249 2302
96.228.9.136 50739
68.221.214.58 50667
189.228.126.78 2302
82.36.136.230 2302
99.140.244.228 2302
67.213.103.78 2302
69.224.34.92 2302
189.58.209.233 15487
190.84.8.120 2302
190.65.182.134 23458
4.129.84.200 2302
98.202.138.233 2302
68.102.138.12 2302
89.156.129.218 61795
98.203.117.231 2302
74.170.16.140 2302
124.45.123.17 44444
67.197.4.222 2302
189.130.91.130 2302
124.45.123.17 42332
24.237.254.232 2302
189.143.92.40 2302
85.48.166.166 2302
186.28.209.109 10463
24.23.83.220 2302
24.237.251.96 2302
70.156.239.236 50306
92.29.33.19 10932
190.40.60.65 27564
201.230.127.220 25728
141.153.174.86 50434
75.141.184.3 36570
87.207.95.213 2302
92.224.37.226 2302
68.172.230.239 2307
189.176.229.224 2302
99.245.43.105 63854
190.20.119.135 19770
96.20.221.74 2302
89.229.239.88 2302
68.193.183.147 2302
124.45.123.17 45445
65.191.97.253 2302
74.61.227.158 2302
85.247.158.70 55157
190.214.120.250 14505
71.50.211.179 2302
189.163.38.105 2302
189.147.98.5 2302
189.170.95.200 2302
124.45.123.17 40440
190.82.2.217 25311
124.45.123.17 43443
68.41.207.162 2302
208.60.181.131 2302
92.201.49.93 2302
97.92.237.181 1507
76.110.54.243 2302
99.20.192.100 2302
69.207.196.27 2302
124.45.123.17 45335
87.9.172.202 2302
60.240.173.36 61202
190.66.154.94 2302
63.162.200.198 14374
70.129.166.82 2302
190.25.24.96 2302


As you can see, they have these annoying spaces. What I want to do:
1. Get rid of the spaces, BUT KEEP A SPACE BETWEEN THE IP AND THE PORT.
2. After the spaces that are bad are gone, I want the program to output each single IP AND port To its own text Box. It doesn't matter is the textbox of the IP and Port are seperated, It can just be one textbox with the IP and port, with a space between them. Thats about it!! I have the GUI done, and the rest of the programming, all I need now is this.
Reformat without spaces > output each seperate line of text to a seperate textbox > TYTYTYTY


PS, is there a way for VB to send a command to the command prompt? Say, I wanted it to open a CMD box and send ipconfig into that box, what would that be? THANKS SO MUCH GUYS!!

ertuu
10-13-2009, 03:49 PM
heyy i created thits program a couple years ago...if you search for author's ertuu you might find a starting step. I might even have the source code around somewhere.

AtmaWeapon
10-13-2009, 04:16 PM
Step 1 I can help you with, Step 2 I'll only give a gentle push, since it's more of a whole application request.

The first thing I'd do is recognize the type of problem. You have a file where each line represents information about a server. You want to read each line and do something with the information about the server. This is a simple parsing application.

There's a million ways to approach this problem, but I feel like this is the best. Start by making a class that represents the data you are parsing. In this case, you might make a ServerInformation class with Address and Port properties. Now, somewhere in your application you want a method that has this signature:
Function Parse(ByVal line As String) As ServerInformation

Now, you want to parse a line that looks like the following:
<whitespace>*<ip Address><whitespace>*<port>

You could use regular expressions for this, but they're a little complicated; they aren't really intended to be parsers but instead are intended for validation. To parse this string, you might write an algorithm like this:

* While the current character is a space:
* Move to the next character

* While the current character is not a space
* Add the current character to the IP address
* Move to the next character

* While the current character is a space:
* Move to the next character

* While the current character is not a space
* Add the current character to the port

It's not that tough to implement, and it gets you what you want. If you use a class like I pointed out, then step 2 is easy because you already have the address and port separated and can create a string that combines them however you want.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum