' vitesse de frappes avec pourcentage de fautes ' OBJETS ' form1 ' text1 propriété multiline=true ' label1 ' label2 ' timer1 Sub Form_Load() ' chargement de texte pour test Label1.Caption = "Je suivais la grande dame vêtue de noir qui marchait d'un pas rapide dans l'allée bordée d'arbres. Il fallait presque que je coure pour ne pas la perdre de vue dans cette nuit glaciale de janvier. Les yeux rougis par le chagrin, de gros sanglots me soulevaient la poitrine. Ma mère venait de m'abandonner, de me mettre en pension comme elle disait et c'était cette grande dame tout en noir qui était à présent responsable de ma destinée." Timer1.Interval = 60000 Timer1.Enabled = False Text1 = "" Label2 = "" End Sub Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) Timer1.Enabled = True ' départ End Sub Sub Timer1_Timer() Dim i As Long Dim ligne1 As String Dim ligne2 As String Dim ligne3 As String Dim lgr1 As Long Dim lgr2 As Long Dim dif As Double Timer1.Enabled = False Text1.Enabled = False lgr1 = Len(Text1.Text) For i = 1 To Len(Label1.Caption) ' test de similarité If Mid(Label1.Caption, i, 1) <> Mid(Text1, i, 1) Then Exit For ligne1 = ligne1 & Mid(Text1, i, 1) Next i lgr2 = Len(ligne1) dif = 100 If lgr1 <> 0 Then dif = 100 / lgr1 * lgr2 For i = 1 To Len(ligne1) ' conservation des signes similaires If Mid(ligne1, i, 1) <> " " Then ligne2 = ligne2 & Mid(ligne1, i, 1) Next i ligne3 "Taux de similarité " & Format(dif, "0.00") & "%" & vbLf ligne3 = ligne3 & Len(ligne2) & " signes par minute" Label2.Caption = ligne3 End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionJ'ai déjà vu cette question récemment ...
Je voudrais faire un programme en vb6 qui calcule la vitesse et la précision de frappe sur un clavier.
Imports System.IO Public Class Form2 Private index As Integer Private line As Integer Private counterrors As Integer Private listwords As New List(Of String) Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Readfile("test1.txt") End Sub Private Sub Readfile(ByVal filename As String) Try listwords = System.IO.File.ReadAllLines(Application.StartupPath & "" & filename).ToList ListBox1.Items.AddRange(listwords.ToArray) index = 0 line = 0 counterrors = 0 Catch ex As Exception End Try End Sub Private Sub RichTextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress Dim ch As Char If index = listwords(line).Length - 1 Then index = 0 If line < listwords.Count Then line += 1 End If End If ch = listwords(line)(index) If e.KeyChar <> ch Then If System.Char.GetUnicodeCategory(e.KeyChar) <> 14 Then e.Handled = True counterrors += 1 Else e.Handled = False End If Else index += 1 End If End Sub End Class
Imports System.IO Public Class Form2 Private index As Integer Private line As Integer Private counterrors As Integer Private listwords As New List(Of String) Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Readfile("test1.txt") End Sub Private Sub Readfile(ByVal filename As String) Try listwords = System.IO.File.ReadAllLines(Application.StartupPath & "" & filename).ToList ListBox1.Items.AddRange(listwords.ToArray) index = 0 line = 0 counterrors = 0 Button1.Enabled = False Catch ex As Exception End Try End Sub Private Sub RichTextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress Dim ch As Char ch = listwords(line)(index) If e.KeyChar <> ch Then If System.Char.GetUnicodeCategory(e.KeyChar) <> 14 Then e.Handled = True counterrors += 1 Else e.Handled = False End If Else index += 1 End If If index = listwords(line).Length Then index = 0 line += 1 If line = listwords.Count Then DirectCast(sender, RichTextBox).Enabled = False Button1.Enabled = True Exit Sub End If End If End Sub Private Sub Button1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseClick MessageBox.Show("nombres d'erreurs de frappe :" & counterrors.ToString) End Sub End Class
C'est dur, cela ?
Qu'il se mette un peu au boulot, d'abord
Moi ce que je cherche c'est de m'orienter, déjà que "ucfoutu" m'a éclairci beaucoup de choses...reste maintenant que j'apprends les bases nécessaires( j'ai réussi jusqu'à maintenant à programmer un seul programme en vb6 celui d'envoi et réception de messages entre deux personnes avec l'utilisation d'un Timer et Winsock)...pour cela si vous avez des liens ou bien des tutos qui peuvent m'être utiles je serai très reconnaissant..