Jump to content
Xtreme .Net Talk

vbMarkO

Avatar/Signature
  • Posts

    158
  • Joined

  • Last visited

vbMarkO's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. THIS IS resolved post code later I rebuilt the code and saw plainly what I was doing wrong ... Mark
  2. Here is my code ... WHat it should do ... is loop through array with addresses in it then display them on a richtextbox However, it loops through does the first one .... then I have to click the button event again for it to get the 2nd one BUT THEN when I click button the 3rd time it doesnt do the third address it simply repeats number 2 Ok, I have moved myInt around ... I even tried putting the whole thing in a do while and then a do until HOwevr I may not hav done eithe of thos right either Please help I just need it to go through each and do to each what its supposed to Oh ... I am going to include my xml file so you can see what its pulling from and to s if you might have any sugestions as to how to do this more efficiently My XML <?xml version ="1.0" encoding ="utf-8"?> <Tulsa> <Streets> <Riverside S61="193,499,100" S71="276,708,1300" S81="400,916,1600" S91="530,1126" S101="589,1334">S Riverside Pkwy</Riverside> <Peoria S61="277,498,1300" S71="271,680,1300">S Peoria Ave</Peoria> <Lewis S61="485,498,2400" S71="485,707,2400" S81="485,916,2400" S91="553,1126,2500">S Lewis Ave</Lewis> <Delaware S61="595,470,2800" S71="595,706,2800" S81="588,916,2800" S91="589,1335,2800">S Delaware Ave</Delaware> <Harvard S61="" S71="" S81="692,916,3300" S91="" S101="">S Harvard Ave</Harvard> <Yale S61="" S71="" S81="901,916,4900" S91="" S101="">S Yale Ave</Yale> </Streets> </Tulsa> My CODE [ Dim myXML As XDocument myXML = XDocument.Load(myXMLPath) Dim myTempArr() As String Dim stString() As String = {"6100 S Riverside Pkwy", "8100 S Yale Ave", "6100 S Peoria Ave"} Dim myString As String = "" Dim myEl() As String myInt += 1 For i = 0 To UBound(stString) If myInt > stString.Count - 1 Then Exit For Else myString = stString(myInt) End If Next myEl = myString.Split(" ") For Each xa In myXML.Descendants For i = 0 To myEl.Count - 1 If myEl(i).ToString() = xa.Name.ToString() Then ' MsgBox(myEl(i)) ' <<<<< Msgbox for testing code If xa.Name = myEl(i) Then myString = Microsoft.VisualBasic.Left(myString, 6).ToString() Dim Sst As String = Microsoft.VisualBasic.Right(myString, 1) Dim streetNum As String = Microsoft.VisualBasic.Left(myString, 4) Dim tAtt As String = Sst & Microsoft.VisualBasic.Left(streetNum, 2) ' MsgBox("String equals - " & tAtt) ' <<<<< Msgbox for testing code myTempArr = xa.Attribute(tAtt).Value.Split(",") For myInt = 0 To UBound(myTempArr) rtb1.Text = rtb1.Text & "Mouse Coordinates Are: " & myTempArr(0) & ", " & myTempArr(1) & vbCrLf _ & "The Hundred Block is " & myTempArr(2) & " E " & vbCrLf & _ "Which is " & myEl(i) & " & " & Microsoft.VisualBasic.Right(tAtt, 2) _ & "st ST" & vbCrLf & vbCrLf Exit For ' Not sure about this Exit For ..... Next End If End If Next Next The future end result of this will be to remove the rtb code all together and replace it with code that will mark the addresses on a map ... I hav that code already written and it works great just ned to be able to search my xml with the addresses contained in the array and mark each point that it finds Mark
  3. Your right .... man ... it was right in front of m and I just knew I was over looking something simple Arrrgh OK then this is solved as that did the trick thanx a bunch Resolved
  4. This I think should loop through placing a picbox at each location But it only places the first one but when I debug it it appeas as though its looping through and I see the coorinates ... I'm just not seeing it happen on my app here is the code Dim PB As New PictureBox Dim myAdds() As String = {"8100 S Riverside", "7100 S Riverside"} Dim myECoord() As Integer = {400, 275} Dim mySCoord() As Integer = {916, 708} ' ToolTip1.SetToolTip(PB, "81st & Riverside Pkwy") For i = 0 To mySCoord.Count - 1 'Dim myInt1 As Integer = myCoord(0) ' Dim myInt2 As Integer = myCoord(1) With PB .Location = New System.Drawing.Point(myECoord(i), mySCoord(i)) .Size = New Size(5, 5) .BackColor = Color.Red .BringToFront() End With Me.PictureBox1.Controls.Add(PB) AddHandler PB.Click, AddressOf MyPicClicked Next Any thoughts Help much appreciated vbMarkO
  5. Yes, I like the idea ... already on to it ... in fact I am playing with it right now ... I have put together a high res map to work with ... the map covers a little more than the area I am concerned with but then thats ok ... Adresses here in Tulsa are the easiest in the world I think ... | | | ___|____ | The Dashed line Up & Down is north and South 8100 of course is 81 blocks from Admiral which is the dividing line for north south anyway then east from Riverside which at 8100 S starts at 1800 Block E Riverside is aproximately 1800 E 81 Street is 8100 S On my image the coordinates are 400, 916 400 is equal to 1800 E 916 is 8100 South WHat I would like to be able to do is determine how figure the math here as to how to calculate the coordinates If the 1800 block of 81st = 400, 916 then what would 3300 block of 81st = ?, 916 Oh and your code ... I am working with it now to loop through ... I will let you know how it turns out as soon as I have the direction I am going to take it Mark
  6. Ok the post was about making picboxes on the fly and the mouse click coordinates I hav now Solved that and the code I showed allowing me to put a single red pixel works but the pixel is so small it wont work .... I woujld lik to continue to play with that or see som help toward that or even better placing an icon like a red arrow or something like that at my coordinate .... I am now looking at modifying the code I am about to show which works great by the way ... to p-lace this programatically outsode of a mouse click but to simply place them based on addresses I pull from data that is placed into arrays ... The addresses I howed in another post of police calls in my area ... I am going to mark them on a map ... each call typ having a different color to show viloent crimes to simple traffic stops. For the first time I really see this happening Ok one last thought ... I do agree that to have a pixle or icon would be best .... SO I am open to example of how I might do this or at least see a working example of how to place multiple icons or plot points on my image map Here is my Working code .... making this htread sort o resolved though I still want to learn more about the othe approach as I only se my code as a work around Dim PB As New PictureBox With PB .Location = New System.Drawing.Point(e.X, e.Y) .Size = New Size(5, 5) .BackColor = Color.Red .BringToFront() End With Me.PictureBox1.Controls.Add(PB) AddHandler PB.Click, AddressOf MyPicClicked End Sub Private Sub MyPicClicked(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Additional code here for clcik event ... but its not needed ' the result of the other code works great it places little red picboxes but ' they look like dots ... its not drawing but its functional End Sub
  7. Hey that code is working ... its just so small I didnt see it I have a pictur box with an image in it ... perhaps I should just put the image on the form and set the picbox color to transparent Yes? Cool ... it at least is starting to do something
  8. I did find this but I get an eror but it oes seem to be what I might want what do you think? Th error is with the e.graphics.drawimageun .... un something cant rember her is the code Dim bm as new Bitmap(1,1) bm.SetPixel(0,0,Color.Red) e.Graphics.DrawImageUnscaled(bm,<xPosition>,<yPosition>) Oh yeah unscaled ... anyway I tried to modify it ... but that didnt work I tried to modify it to this .. but I am not sure this is right well I know its not as its not doing anything Also this is within a Picturebpox1_MouseClick Dim mPen As New Bitmap(1, 1) mPen.SetPixel(0, 0, Color.Red) Dim g As Graphics g = PictureBox1.CreateGraphics g.DrawImageUnscaled(mPen, e.X, e.Y) Ok ... anythoughts
  9. Yes ..... but I am not sure how todo this this is why I cam up with that I have been searching fo just putting a point at the location but th only thing close I found was in C# ... I know its clos but I couldnt get it to work ... could you point me to a simple VB example or show an example?
  10. This will move one to a given location pic2.Location = New System.Drawing.Point(175, 252) pic2.Visible = True But I want to create them and I would like assign the locations based 2 things 1. Mouse click ...... 2. but would also like doing this using variables o an array of coordinate integers I tried this to create ... Dim pct As New PictureBox() pct.Location = New System.Drawing.Point(177, 228) pct.Size = New System.Drawing.Size(5, 5) pct.BackColor = Color.Red pct.BringToFront() Me.Controls.Add(pct) but I couldnt figure out how to ad the handler or assign address of for a picture box not evn sur if this is right ... I sort of think Im on the right track though This really worked fin with the button event ... I clicked on it and the red spot went right wer I wanted it to ... I know its not high end drawing stuff but I dont know about that and this is a great work around for me .. I just need to figure out how to assign the coordinates and crate the picture boxes or get the mouse click coordinate and assign it The idea is to have multiple pictureboxs acting as my littl red dots to mark my map ... sure looks like a grat idea All help appreciated .... vbMarkO
  11. Here is the code modified sort o just made it fit what I already have but .... I havent figured out yet how to compare the final results to then determine the address closest to farthest away I am putting th whole thing in so you can see what I am trying to do Note I am only pulling out South addresses here .... I tried to start with one side then do the other the East addresses Its like this |_7100 S_______|3000 E | | |_8100 S_______|3000 E | | |_9100 S_______|3000 E This very crude map above gives an idea of what I am shooting for location is just below 81st S .... we can call it 8100 anyway I am logging various crime activity within a 2 mile radius so to speak 2 miles North of 8100 which my map above only shows 1 mile but then also 2 miles E and it dos reflect aprox 2 miles The addresses are in an array in the above format ..... my thoughts or approach maybe the wrong way ... maybe there is an easier way to figure coordinates ... but my idea was simply to find the smallest number south or north of 8100 then East of 8100 .... no need to wory about W as I am against the river ..... Dim addArr() As String = {"6100 S Lewis Ave", "4100 S Yale Ave", "3900 E 28 ST S", _ "2100 S Jackson Ave", "3100 S Yale Ave", "7800 S Jamestown Ave", _ "1900 E 49 ST S", "2400 S Maybelle Ave", "7600 S Jamestown Ave", _ "2400 E 71 ST S", "9800 S Lewis Ave", "6300 S Riverside Pkwy"} For sIn = 61 To 100 For Each item In addArr If item.Contains(sIn & "00 S") Then 'lstS.Items.Add(item) Dim myInt As Integer = "7700" 'Dim sArr As New ArrayList If item.Contains(sIn & "00") Then item = Microsoft.VisualBasic.Left(item, 4) '////////////NEW PARSE CODE HERE Dim sNumArr As New ArrayList sNumArr.Add(item) Dim sInt As Integer = 7700 Dim res = From nums In sNumArr _ Let diff = Math.Abs(Convert.ToInt32(nums) - sInt) _ Order By diff _ Group nums By diff _ Into DistanceGroup = Group _ Select New With {.Difference = diff, .NumberOfMatches = DistanceGroup.Count, DistanceGroup} 'just print out to debug as an example For Each x In res ' Debug.WriteLine(String.Format("Distance {0}, Number Of Matches {1}", x.Difference, x.NumberOfMatches)) lstE.Items.Add(String.Format("Distance {0}, Number Of Matches {1}", x.Difference, x.NumberOfMatches)) For Each number In x.DistanceGroup 'Debug.WriteLine(String.Format("Original number {0}", number)) lstS.Items.Add(String.Format(String.Format("Original number {0}", number))) ' Below rtb1.text I put to se what it looked like compared to lsitbox items ' Its letting m know in the first for each ... smallest distances and largest distances ' Now I am trying to figur out how to return 1. smallest distance (which is closest) '............................................2. next small and so on .... ' this does at last give me the distances to compare ... thank you I do appreciate that rtb1.Text = rtb1.Text & number & vbCrLf Next Next End If End If Next Next
  12. Ok I have made some headway but still not there yet .... I am now getting a clean split but I realize something that I am not sure what to do with Obviously I am wanting to take the string as seen in this partial example of the string Example string Dim exampString as String exampString = "Name: John Smith Race: White" ect ect ect ect My code is now returning this Name John Smith Race White ................. continues till it gets to TPD# then does this TPD# summary text ...... and so on .... but the problem is not in the co as much as it is the strings it will be parsing most ar as above but a few will have a middle name to like Dim exampString As String exampString = "Name: Mary Jane Smith Race: White Sex: Female" and so on ....... If they didnt have the middle name my problem would be solved but the it is I may be going about this still all wrong though as what I am wanting to do is put it back together in an order like this Name: John Smith or John William Smith should a middle name exist Race: White Sex: Male Age: 45 continuing this on down to TPD# summary text ...... like that perhaps you guys could you point a better direction o what I might be overlooking all help is much appreciated vbMarkO ooops forgot to ad the code here it is Dim values As String values = "Name: Lanton Lamho Race: White Sex: Male Age: 18 DOB: 05-10-90 Height: 5’06 Weight: 152 Hair: Blk Eyes: Brown TPD#Lanton Lamho broke into the Quickie Mart located at 5310 S. Peoria Ave. The suspect used a manhole cover to throw..." Dim myString As String() = Nothing Dim sep(3) As Char sep(0) = ": " sep(1) = " Race:" sep(2) = " DOB:" myString = values.Split(sep, 29) Dim s As String Dim sArr As New ArrayList For Each s In myString sArr.Add(s).ToString.Replace(" ", ",") Next s For i = 0 To sArr.Count - 1 If sArr(i) = "" Then Else rtb1.Text = rtb1.Text & sArr(i).ToString.Trim(" ") & vbCrLf End If Next
  13. VB 2008 Express :)
  14. Ok here is what I am trying to do first the contents of the string I have an array that has forty or more of the following each element of the array contains data like this I need to parse Name: Lanton Lamho Race: White Sex: Male Age: 18 DOB: 05-10-90 Height: 5�06 Weight: 152 Hair: Blk Eyes: Brown TPD#Lanton Lamho broke into the Quickie Mart located at 5310 S. Peoria Ave. The suspect used a manhole cover to throw... NOTE!!!!!! Some of the names are first middle last not just first and last Anyway I need I need descriptions in labels and info in other labels like this Name: John Smith Race: White Sex: Male Age: 25 ect ect until it gets to the TPD# I need that stripped and all following put into a label of its own ie; Guy did what ever he did and he is in trouble for it LOL anyway .... I tried a multiple delimiter spit but the results left empty elements of the array .... Anyone got some ideas how I might best parse this? Heres the code I used and tried to modify but it wont work exactly right Dim values As String values = "Name: John Smith Race: White DOB: 1/22/60" Dim sites As String() = Nothing Dim sep(3) As Char sep(0) = ": " sep(1) = " Race:" sep(2) = " DOB:" sites = values.Split(sep, 9) Dim s As String For Each s In sites rtb1.Text = rtb1.Text & s.Trim(" ") & vbCrLf Next s Help much appreciated Mark
  15. This code is almost perfect but it does have one problem but then that might be my fault as you wrote it to search what I put in my array example I tested it and it found 7900 which in the example is correct its closest but put two numbers that are just as close then it chooses only one I added another number I put 7600 in and changed the 7900 to 7800 the code returned 7800 as closest but in fact the 2 are the same distance away .. Ok now let me share what it is I am doing and why ..... I am writing a program that monitors all the police calls iin my area. In fact that part is done and it works great .... the addresses of the calls are stripped and entered into arrays ... like the one I showed you there is a south array for the address containing IE; 7500 S ST, 8600 S another ST The other array is for East 1500 E you get it ST Anyway, I am highlighting in an RTB the calls that are within 2 miles of a specific address .... it is to assist us in keeping an eye on certain calls of conern in our area. So this is why ... thanx for the code by the way I will see if I can figure out how to get adresses that are closest and or also determine those that are equally as close. Mark
×
×
  • Create New...