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

Paradise GTP

Premium
Inscription
30 Juin 2013
Messages
4 265
Réactions
4 409
Points
21 005
RGCoins
70
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:

Grégory

Développeur
Ancien staff
Inscription
14 Novembre 2011
Messages
2 798
Réactions
2 221
Points
25 358
RGCoins
0
Tu ne t'arrête plus dis donc :D
GG !
 

Ability'Broh

Je suis comme je suis ,si t'aime pas c'est pareil.
Premium
Inscription
2 Décembre 2011
Messages
638
Réactions
187
Points
17 111
RGCoins
25
Je commence a m’intéresser a ceux truc :D
 
D

deleted226438

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
 

GDK

C’est plus ce que c’était..
Premium
Inscription
29 Avril 2013
Messages
2 730
Réactions
992
Points
17 988
RGCoins
0
C'est intéressant sa.
 
Haut