Advertisement
Guest User

Soluzione cancerogena alla lepre (fattela piacere)

a guest
Feb 20th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.51 KB | None | 0 0
  1. Imports System.Text
  2. Imports System.Text.RegularExpressions
  3.  
  4. Public Class Main
  5.  
  6.     Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.  
  8.     End Sub
  9.  
  10.     Private Sub btn_apri_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_apri.Click
  11.         Try
  12.             dialog_apri.ShowDialog()
  13.             txt_programma.Text = My.Computer.FileSystem.ReadAllText(dialog_apri.FileName, Encoding.Default)
  14.         Catch
  15.  
  16.         End Try
  17.     End Sub
  18.  
  19.     Private Sub btn_correggi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_correggi.Click
  20.         Dim programma As String
  21.         programma = txt_programma.Text
  22.         Dim resultstring As String
  23.         Dim rgx As New Regex("(?mn)^N\d+ ")
  24.         Dim replacement As String = ""
  25.         resultstring = rgx.Replace(programma, replacement)
  26.         txt_programma.Text = resultstring
  27.     End Sub
  28.  
  29.     Private Sub btn_salva_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_salva.Click
  30.         Try
  31.             dialog_salva.ShowDialog()
  32.             My.Computer.FileSystem.WriteAllText(dialog_salva.FileName, txt_programma.Text, False)
  33.             MessageBox.Show("File salvato in: " + vbCrLf + dialog_salva.FileName, "Salvataggio", MessageBoxButtons.OK, MessageBoxIcon.Information)
  34.         Catch
  35.             MessageBox.Show("Qualcosa รจ andato storto", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error)
  36.         End Try
  37.     End Sub
  38. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement