Advertisement
Guest User

Untitled

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