Advertisement
Guest User

Untitled

a guest
Mar 26th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.56 KB | None | 0 0
  1. Imports System.Net
  2. Imports System.IO
  3. Imports System.Text.RegularExpressions
  4. Imports System.Text
  5. Imports System.Web
  6. Imports System
  7.  
  8. Public Class Form1
  9.     Private meinRegex As New Regex("<.*?model=""(\d*)"".*?dimension=""(\d*)"".*?></object>", RegexOptions.Multiline)
  10.  
  11.     Dim curStatus As String = "-"
  12.     Dim integerwert As Integer = 0
  13.  
  14.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  15.  
  16.        
  17.  
  18.  
  19.        
  20.         ListBox1.Items.Clear()
  21.         ListBox2.Items.Clear()
  22.         Dim t As New OpenFileDialog
  23.         If t.ShowDialog = vbOK Then
  24.             Dim pfad As String = t.FileName
  25.             Dim mytext As String = My.Computer.FileSystem.ReadAllText(pfad)
  26.             Dim myTextList = mytext.Split(vbNewLine)
  27.             For Each line In myTextList
  28.                 ListBox1.Items.Add(line)
  29.                 ListBox2.Items.Add(line)
  30.             Next
  31.         End If
  32.     End Sub
  33.  
  34.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  35.         RadioButton2.Select()
  36.     End Sub
  37.  
  38.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  39.  
  40.         Try
  41.             Dim ntext As Integer = CInt(TextBox1.Text)
  42.             Try
  43.                 integerwert = CInt(TextBox2.Text)
  44.             Catch ex2 As Exception
  45.                 Return
  46.             End Try
  47.         Catch ex As Exception
  48.             Return
  49.            
  50.         End Try
  51.  
  52.         If RadioButton1.Checked = True Then
  53.             curStatus = "+"
  54.         Else
  55.             curStatus = "-"
  56.         End If
  57.         Dim mydex As Integer = 0
  58.         Dim groups1 As GroupCollection
  59.  
  60.         For Each item In ListBox1.Items
  61.             mydex += 1
  62.             ' Hier abfragen
  63.             Dim MC1 As MatchCollection = meinRegex.Matches(item)
  64.  
  65.  
  66.  
  67.  
  68.             If MC1.Count > 0 Then
  69.                 For Each items As Match In MC1
  70.  
  71.                     groups1 = items.Groups
  72.                     Dim sell As Integer = groups1.Count()
  73.                     If (groups1.Item(1).Value()) = TextBox1.Text Then
  74.                         Dim curDIm As Integer = CInt(groups1.Item(2).Value())
  75.                         If curStatus = "-" Then
  76.                             Dim newvalue As Integer = (curDIm - integerwert)
  77.                             'ListBox2.Items.RemoveAt(mydex)
  78.                             'ListBox2.Items.Add(groups1.Item(0).Value.Replace("dimension=""" & curDIm & """", "dimension=""" & newvalue & """"))
  79.                             ListBox2.Items.Item(mydex) = groups1.Item(0).Value.Replace("dimension=""" & curDIm & """", "dimension=""" & newvalue & """")
  80.                         Else
  81.                             Dim newvalue As Integer = (curDIm + integerwert)
  82.                             'ListBox2.Items.RemoveAt(mydex)
  83.                             ListBox2.Items.Item(mydex) = groups1.Item(0).Value.Replace("dimension=""" & curDIm & """", "dimension=""" & newvalue & """")
  84.                             'ListBox2.Items.Add(groups1.Item(0).Value.Replace("dimension=""" & curDIm & """", "dimension=""" & newvalue & """"))
  85.                         End If
  86.                     End If
  87.  
  88.                 Next
  89.             End If
  90.         Next
  91.     End Sub
  92.  
  93.     Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
  94.         Try
  95.             TextBox3.Text = ListBox2.SelectedItem.ToString
  96.         Catch ex As Exception
  97.  
  98.         End Try
  99.     End Sub
  100. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement