Advertisement
Guest User

Untitled

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