Tutoriel [VB.NET] Créer un logiciel de traitement de texte

Paradise GTP

Premium
Inscription
30 Juin 2013
Messages
4 271
Réactions
4 414
Points
24 105
RGCoins
519
You must be registered for see images attach


Hello, on ce retrouve pour un tutoriel.
Donc voila l'interface du logiciel

You must be registered for see images attach


Donc vous aurez besoin de mettre :
- Une textBox
- Un menustrip
- Un label
- Un SaveFileDialog
- Un OpenFileDialog
- Un ColorDialog

Dans le menu strip :
Le menu Fichier avec dedans :
- Nouveau
- Enregistrer
- Imprimer
- Ouvrir

Le menu Police avec dedans :
- Police
- Couleur
- Alignement
Avec dans le menu alignement :
Droite
Gauche
Centré

Voila :espion:

Avant tous importer sa :
Code:
[/CENTER]
Imports System.IO
Imports System.Drawing.Font
Imports System.Drawing.Printing

You must be registered for see images attach


Programmation du SaveFileDialog et OpenFileDialog sont les même :
Filter :
Code:
Fichier Texte|".txt

Donc le bouton nouveau :
Code:
  TextBox1.Text = ""

Dans le bouton Ouvrir :
Code:
[/CENTER]
  If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  Dim SR As New StreamReader(OpenFileDialog1.FileName)
  TextBox1.Text = SR.ReadToEnd
  SR.Close()
  End If

Dans le bouton enregistrer :
Code:
  If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

  Dim SW As New StreamWriter(SaveFileDialog1.FileName)
  SW.Write(TextBox1.Text)
  SW.Close()
  End If

Dans le bouton imprimer :
Code:
  Try
  Dim PrintDoc As New PrintDocument
  AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
  PrintDoc.Print()
  Catch ex As Exception
  MessageBox.Show("Désolé nous ne pouvons pas imprimer ce doccument", ex.ToString())
  End Try

Dans le bouton couleur :
Code:
  If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  TextBox1.ForeColor = ColorDialog1.Color
  End If

Dans le bouton Police :
Code:
  Dim instance As New FontDialog
  instance.ShowDialog()
  TextBox1.Font = instance.Font

Dans le bouton centré :
Code:
  TextBox1.TextAlign = HorizontalAlignment.Center

Dans le bouton droite:
Code:
  TextBox1.TextAlign = HorizontalAlignment.Right

Dans le bouton droite:
Code:
  TextBox1.TextAlign = HorizontalAlignment.Left

Et pour finir dans la textBox :
Code:
  Label1.Text = Len(TextBox1.Text) & " caractères"

Voila ces codes ne sont pas que pour un traiteur de texte, vous pouvez les utilisez pour tout autre choses
Tutoriel écrit, screen 100% by Boosterz.
Le copié collé est strictement INTERDIT
Cordialement,
Boosterz GTP
 
Dernière édition:
Tu ne t'arrête plus dis donc :D
GG !
 
Je commence a m’intéresser a ceux truc :D
 
You must be registered for see images attach


Hello, on ce retrouve pour un tutoriel.
Donc voila l'interface du logiciel

You must be registered for see images attach


Donc vous aurez besoin de mettre :
- Une textBox
- Un menustrip
- Un label
- Un SaveFileDialog
- Un OpenFileDialog
- Un ColorDialog

Dans le menu strip :
Le menu Fichier avec dedans :
- Nouveau
- Enregistrer
- Imprimer
- Ouvrir

Le menu Police avec dedans :
- Police
- Couleur
- Alignement
Avec dans le menu alignement :
Droite
Gauche
Centré

Voila :espion:

Avant tous importer sa :
Code:
[/CENTER]
Imports System.IO
Imports System.Drawing.Font
Imports System.Drawing.Printing

You must be registered for see images attach


Programmation du SaveFileDialog et OpenFileDialog sont les même :
Filter :
Code:
Fichier Texte|".txt

Donc le bouton nouveau :
Code:
  TextBox1.Text = ""

Dans le bouton Ouvrir :
Code:
[/CENTER]
  If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  Dim SR As New StreamReader(OpenFileDialog1.FileName)
  TextBox1.Text = SR.ReadToEnd
  SR.Close()
  End If

Dans le bouton enregistrer :
Code:
  If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

  Dim SW As New StreamWriter(SaveFileDialog1.FileName)
  SW.Write(TextBox1.Text)
  SW.Close()
  End If

Dans le bouton imprimer :
Code:
  Try
  Dim PrintDoc As New PrintDocument
  AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
  PrintDoc.Print()
  Catch ex As Exception
  MessageBox.Show("Désolé nous ne pouvons pas imprimer ce doccument", ex.ToString())
  End Try

Dans le bouton couleur :
Code:
  If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  TextBox1.ForeColor = ColorDialog1.Color
  End If

Dans le bouton Police :
Code:
  Dim instance As New FontDialog
  instance.ShowDialog()
  TextBox1.Font = instance.Font

Dans le bouton centré :
Code:
  TextBox1.TextAlign = HorizontalAlignment.Center

Dans le bouton droite:
Code:
  TextBox1.TextAlign = HorizontalAlignment.Right

Dans le bouton droite:
Code:
  TextBox1.TextAlign = HorizontalAlignment.Left

Et pour finir dans la textBox :
Code:
  Label1.Text = Len(TextBox1.Text) & " caractères"

Voila ces codes ne sont pas que pour un traiteur de texte, vous pouvez les utilisez pour tout autre choses
Tutoriel écrit, screen 100% by Boosterz.
Le copié collé est strictement INTERDIT
Cordialement,
Boosterz GTP
Merci :D
 
C'est intéressant sa.
 
Retour
Haut