test12 = MsgBox(" ...... ")
If test12 = vbYes Then
If variable = 1 Then variable = 0 ' le reste du code...
if form2.button1.clik = true then...
Private Sub ButtonBegin_Click() Dim test7 As Integer UserForm1.Show If variable = 1 Then IS_NEW = True OF_NAME.Caption = Range("I2") Range("A2:A5000").Value = "" 'rend vierge les case de l'intervalle Range("B2:B5000").Value2 = "" ' pareil ColorBox.BackColor = &H8000000F Nb_line = 0 Label5.Caption = "Vide" OF = "TestOF" Range("A2:A5000").Offset(Nb_line, 0).Interior.Color = vbWhite Range("B2:B5000").Offset(Nb_line, 0).Interior.Color = vbWhite Label5.BackColor = &H8000000F ButtonBegin.Enabled = False Ordredefabrication = InputBox("Indiquez le numéro d'OF :") Range("I2").Value = Ordredefabrication If Ordredefabrication = "" Then test7 = MsgBox("Vous n'avez pas rentré de N° d'OF", vbOKOnly + vbExclamation, "Programme de pesée") ButtonBegin.Enabled = True End If If ButtonBegin.Enabled = False Then 'rend le bouton Début inactif End If End If If variable = 2 Then IS_NEW = False Dim Nb_l Nb_l = Range("A5000").End(xlUp).Row - 1 Nb_line = Nb_l Label5.Caption = "Vide" OF_NAME.Caption = Range("I2") OF = "TestOF" Label5.BackColor = &H8000000F ButtonBegin.Enabled = False Ordredefabrication = Range("I2") End If End Sub
Dim variable As String Private Sub CommandButton1_Click() variable = 1 End Sub Private Sub CommandButton2_Click() variable = 2 End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic variable As Integer
Qu'est ce que tu appelle "un code non indenté"
Public bReponse As BooleanC'est cette variable qui stockera le résultat des boutons.
Dim maForme As frmMsgBox Set maForme = New frmMsgBox With maForme .maTextBox.Text = "Texte de ma question" .Show ' Ouvre et attend la fermeture de la forme ' Suite du code plus bas
Private Sub cmdOui_Click() bReponse = True Me.Hide End Sub Private Sub cmdNon_Click() bReponse = False Me.Hide End SubIl faut utiliser .Hide pour masquer la forme, mais c'est le code appelant qui la déchargera, après avoir lu le résultat :
' Voilà la suite du code : If .bReponse = True Then ' Ici le code quand réponse Oui Else ' Ici le code quand réponse Non End If End With ' Déchargement de la forme Unload maForme Set maForme = Nothing
Sub lecture() 'Lecture du port série et renvoi la valeur dans k Dim sInput As String Dim Count As Integer Count = 0 For Count 0 To 100000 ' Pour plus long mais plus sur : Count 250 000, Pour plus rapide Count = 50 000 Application.DoEvents() ' Laisse la main à windows sInput = XMCommCRC1.Input If (Len(sInput) > 0) Then TextBox1.SelectedText = sInput s If (Len(TextBox1.Text) > 1) Then TextBox1.SelectionStart = 0 TextBox1.SelectionLength = 2 k = TextBox1.SelectedText Count = 100000 End If End If Next Count 'Incrémentation de Count If (Len(TextBox1.Text) <= 1) Then 'Si on ne recois pas de données avant la fin de la boucle TextBox1.Text = "" 'on efface la texbox pour les prochaines lectures k 48 'k 48 dans le sous programme 'cas analyse' va appeller le sous programme qui traite du retard End If TextBox1.Text = "" 'on efface la texbox pour les prochaines lectures End Sub
Sub lecture() 'Lecture du port série et renvoi la valeur dans k Dim sInput As String Dim Count As Integer Count = 0 For Count 0 To 100000 ' Pour plus long mais plus sur : Count 250 000, Pour plus rapide Count = 50 000 Application.DoEvents() ' Laisse la main à windows sInput = XMCommCRC1.Input If (Len(sInput) > 0) Then TextBox1.SelectedText = sInput s If (Len(TextBox1.Text) > 1) Then TextBox1.SelectionStart = 0 TextBox1.SelectionLength = 2 k = TextBox1.SelectedText Count = 100000 End If End If Next Count 'Incrémentation de Count If (Len(TextBox1.Text) <= 1) Then 'Si on ne recois pas de données avant la fin de la boucle TextBox1.Text = "" 'on efface la texbox pour les prochaines lectures k 48 'k 48 dans le sous programme 'cas analyse' va appeller le sous programme qui traite du retard End If TextBox1.Text = "" 'on efface la texbox pour les prochaines lectures End Sub
Private Sub ButtonBegin_Click() Dim test7 As Integer Dim test12 As Integer test12 = MsgBox("Appuyez sur 'oui' si il s'agit d'un nouvel OF" & vbCrLf & "Appuyez sur 'non' s'il s'agit d'une reprise", vbYesNoCancel + vbExclamation, "Programme de pesée") If test12 = vbYes Then IS_NEW = True Range("A2:A5000").Value = "" 'rend vierge les case de l'intervalle Range("B2:B5000").Value2 = "" ' pareil ColorBox.BackColor = &H8000000F Nb_line = 0 Label5.Caption = "Vide" OF = "TestOF" Range("A2:A5000").Offset(Nb_line, 0).Interior.Color = vbWhite Range("B2:B5000").Offset(Nb_line, 0).Interior.Color = vbWhite Label5.BackColor = &H8000000F ButtonBegin.Enabled = False Ordredefabrication = InputBox("Indiquez le numéro d'OF :") Range("I2").Value = Ordredefabrication Label6.TextAlign = fmTextAlignCenter Label6.Caption = "Ordre de fabrication N° " & Ordredefabrication If Ordredefabrication = "" Then test7 = MsgBox("Vous n'avez pas rentré de N° d'OF", vbOKOnly + vbExclamation, "Programme de pesée") ButtonBegin.Enabled = True End If If ButtonBegin.Enabled = False Then 'rend le bouton Début inactif End If End If If test12 = vbNo Then IS_NEW = False Dim Nb_l Nb_l = Range("A5000").End(xlUp).Row - 1 Nb_line = Nb_l Label5.Caption = "Vide" OF = "TestOF" Label5.BackColor = &H8000000F ButtonBegin.Enabled = False Ordredefabrication = Range("I2") End If End Sub
With maForme .maTextBox.Text = "Texte de ma question" .Show
ça m'a coupé toute les étapes du code :/