Private Sub UserForm_Initialize() Me.Move 0, 0, 500, 1000 With Label1 .Font.Name = "Courier" .Font.Size = 10 .Move 10, 20, 600, 20 .BackStyle = 0 .Caption = "" End With With Label2 .Font.Name = "Courier" .Font.Size = 10 .Move Label1.Left, Label1.Top + 5, Label1.Width, Label1.Height .BackStyle = 0 .Caption = "" End With End Sub Private Sub CommandButton1_Click() Dim toto As String, c1 As String, c2 As String, i As Integer, ouille As Boolean, ahlala As String toto "2(SO4)3Fe2 + 12K(SCN) 2K3Fe(SCN)6 + 3K2SO4" c1 = toto c2 = toto ahlala = " (+=" For i = 1 To Len(toto) 'quoi = Mid(toto, i, 1) If i > 1 Then If IsNumeric(Mid(toto, i, 1)) Then If Not IsNumeric(Mid(toto, i - 1, 1)) And InStr(ahlala, Mid(toto, i - 1, 1)) = 0 Then ouille = True End If End If End If If ouille Then Mid(c1, i, 1) = " " Else Mid(c2, i, 1) = " " End If ouille = False Next Label1.Caption = c1 Label2.Caption = c2 End Sub
Comprenez la subtilité du truc?
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionle problème est que ce qu'il faut écrire dans le Msgbox est loin d'être figé.
le problème est que ce qu'il faut écrire dans le Msgbox
Dim Formule As String Formule = "C78O" Dim Chiffre As String For i = 1 To Len(Formule) If IsNumeric(Mid(Formule, i, 1)) Then Chiffre = Chiffre & Mid(Formule, i, 1) Next MsgBox "La Formule " & Formule & " contient le chiffre " & Chiffre
Par contre H²O, d'après mes souvenirs (hé oui ça remonte ) ce qui représente deux molécules de oxygène, ça s'écrit H2O.