Novice - Erreur de compilation : Else sans If !

Llyod

XLDnaute Nouveau
Bonsoir,

Je bloque depuis une journée sur cette erreur de compilation. J'ai parcouru les forums en long et en large, et je sais que cette erreur vient du fait que la structure de ma condition n'est pas bonne. J'ai essayé d'ajouter des alinéas sans succès.

Voici mon code :

Private Sub commandbutton1_Click()

'Condition remplissage pour écrire dans le tableau -->

If (TextBox1.Value <> "" And TextBox2.Value <> "" And TextBox3.Value <> "" And TextBox4.Value <> "") Then

'Valeur de la case Nom dans le tableau
Dim a As Integer

With Worksheets("Feuil1")
'Déclaration de la variable "der_cell"
a = Columns("C").Find("", Range("C1"), xlValues).Row 'variable = recherche de la dernière ligne de la colonne "C"
Cells(a, "C") = TextBox1


'Valeur de la case Prénom dans le tableau
Dim der_cell2 As Integer
der_cell2 = Columns("D").Find("", Range("D1"), xlValues).Row
Cells(der_cell2, "D") = TextBox2

'Valeur de la case Licence dans le tableau
Dim der_cell3 As Integer
der_cell3 = Columns("E").Find("", Range("E1"), xlValues).Row
Cells(der_cell3, "E") = TextBox3

'Valeur de la case Villes dans le tableau
Dim der_cell4 As Integer
der_cell4 = Columns("F").Find("", Range("F1"), xlValues).Row
Cells(der_cell4, "F") = TextBox4

Unload Me
Else

'Vérification Textbox rempli sinon messagebox
If TextBox1.Value = "" Then MsgBox "Indiquez le nom du joueur"

'Vérification Textbox rempli sinon messagebox
If TextBox2.Value = "" Then MsgBox "Indiquez le prenom du joueur"

'Vérification Textbox rempli sinon messagebox
If TextBox3.Value = "" Then MsgBox "Indiquez le numéro de licence sinon inscrire non-licencié"

'Vérification Textbox rempli sinon messagebox
If TextBox4.Value = "" Then MsgBox "Indiquez une ville"

End If
End With

Application.ScreenUpdating = True
Worksheets("Tournoi").Activate


End Sub


Merci pour l'aide !

Baptiste
 
Dernière modification par un modérateur:

Roland_M

XLDnaute Barbatruc
Re : Novice - Erreur de compilation : Else sans If !

bonsoir,

voilà une routine, à placer dans un module, qui adapte un userf à la résolution ainsi que le positionnement
avec le code à placer dans l'userform pour l'appel de cette routine.

'1 PLACER CECI DANS VOS USERFORM
Code:
'Position=""ou"centre" "haut" "<haut" "haut>" "bas" "<bas" "bas>"
Private Sub UserForm_Initialize()
'ResolutionX, ResolutionY sont la résolution d'origine à la création de votre userf
'UserformZoom Me, ResolutionX, ResolutionY, "centre" '< pour zoom à la résolution avec position
UserformZoomEcran Me                                '< pour zoom plein écran sera centré
End Sub

'2 PLACER CE CODE DANS UN MODULE (NE RIEN MODIFIER)
Code:
Public Sub UserformZoom(fmME As Object, RxDeBase%, RyDeBase%, PosFmME$)
Dim LargScrPoint%, HautScrPoint%, RxActuel%, Rap@, W@, H@
LargScrPoint% = FScreenWidthPoint
HautScrPoint% = FScreenHeightPointSurBarreTaches '!sur barre!
RxActuel = FResolutionXwinPixel
If RxDeBase <= 0 Then RxDeBase = RxActuel
If RxActuel <> RxDeBase Then
   If RxActuel > RxDeBase Then
      Rap = RxActuel / RxDeBase: Rap = 1 + ((Rap - 1) * 0.2)
   Else
      Rap = RxDeBase / RxActuel: Rap = 1 - ((Rap - 1) * 0.2)
   End If
   If Rap > 4 Then Rap = 4 'avec zoom 400 maxi
   If Rap <= 0 Then Rap = 0.1 'mini 100*0.1=10
Else: Rap = 1
End If
'ZOOM/REDIM USERF
W = FEpaisBordUserfPoint * 2: H = FHautBarreUserfPoint
With fmME
 .Zoom = 100 * Rap
 .Width = (.Width - W) * Rap + W
 .Height = (.Height - H) * Rap + H
  'limite débordement avec zoom
  W = .Width / .Zoom: H = .Height / .Zoom
  While (.Width > LargScrPoint Or .Height > HautScrPoint) And .Zoom > 10
    .Zoom = .Zoom - 1: .Width = .Zoom * W: .Height = .Zoom * H
  Wend
  'si pas de position recentre
  If PosFmME$ = "" Then
    .StartUpPosition = 0
    .Top = (HautScrPoint - .Height) * 0.5
    .Left = (LargScrPoint - .Width) * 0.5
     If (.Top + .Height + FHautBarreUserfPoint) > HautScrPoint Then .Top = 1
  End If
End With
'position
If PosFmME$ > "" Then UserformPosition fmME, PosFmME$
End Sub

Public Sub UserformZoomEcran(fmME As Object)
Dim LargScrPoint%, HautScrPoint%, RW@, RH@
LargScrPoint = FScreenWidthPoint
HautScrPoint = FScreenHeightPointSurBarreTaches '!sur barre!
With fmME
 .StartUpPosition = 0: .Top = 0: .Left = 0 'haut/gauche
 'agrandi au maxi écran
 RW = .Width / .Zoom: RH = .Height / .Zoom
 While .Width < LargScrPoint And .Height < HautScrPoint And .Zoom < 400 'maxi
   .Zoom = .Zoom + 1: .Width = .Zoom * RW: .Height = .Zoom * RH
 Wend
 'diminue si trop grand
 RW = .Width / .Zoom: RH = .Height / .Zoom
 While (.Width > LargScrPoint Or .Height > HautScrPoint) And .Zoom > 10 'mini
   .Zoom = .Zoom - 1: .Width = .Zoom * RW: .Height = .Zoom * RH
 Wend
 'centre
 .Left = (LargScrPoint - .Width) * 0.5
 .Top = (HautScrPoint - .Height) * 0.5
End With
End Sub

'EXTRAIT DE ModSTD_RoutDivers mais nettoyé pour ici !!!
Public Sub UserformPosition(fmME As Object, PosFmME$)
W% = FScreenWidthPoint: H% = FScreenHeightPointSurBarreTaches: Bord% = FEpaisBordUserfPoint
With fmME
 .StartUpPosition = 0
Select Case LCase(PosFmME$)
  Case "haut", "<haut>": .Top = Bord: .Left = (W - .Width) * 0.5
  Case "<haut":          .Top = Bord: .Left = Bord
  Case "haut>":          .Top = Bord: .Left = W - .Width - Bord
  Case "bas", "<bas>": .Top = H - .Height - Bord: .Left = (W - .Width) * 0.5
  Case "<bas":         .Top = H - .Height - Bord: .Left = Bord
  Case "bas>":         .Top = H - .Height - Bord: .Left = W - .Width - Bord
  Case Else: .StartUpPosition = 2 'centre avec test s'il n'est pas sous la barre des taches
       If (.Top + .Height + FHautBarreUserfPoint) > FScreenHeightPointSurBarreTaches Then .StartUpPosition = 0: .Top = Bord: .Left = (W - .Width) * 0.5
End Select
If .Top < 0 Then .Top = 1
If .Left < 0 Then .Left = 1
End With
End Sub
'sans API et simplifié pour cet exemple
Public Function FPointsParPixel@(): FPointsParPixel = 0.75: End Function
Public Function FResolutionXpixel%(): FResolutionXpixel = FResolutionXwinPixel: End Function
Public Function FResolutionYpixel%(): FResolutionYpixel = FResolutionYwinPixel: End Function
Public Function FResolutionXwinPixel%(): FResolutionXwinPixel = (Application.Width - 12) / FPointsParPixel: End Function
Public Function FResolutionYwinPixel%(): FResolutionYwinPixel = (Application.Height + 18) / FPointsParPixel: End Function
Public Function FScreenWidthPoint%(): FScreenWidthPoint = FResolutionXpixel * FPointsParPixel: End Function
Public Function FScreenHeightPoint%(): FScreenHeightPoint = FResolutionYpixel * FPointsParPixel: End Function
Public Function FScreenHeightPointSurBarreTaches%(): FScreenHeightPointSurBarreTaches = FScreenHeightPoint - FHautBarreDesTachesPoint: End Function
Public Function FHautBarreDesTachesPoint%(): FHautBarreDesTachesPoint = 30: End Function
Public Function FHautBarreUserfPoint%(): FHautBarreUserfPoint = 22: End Function
Public Function FEpaisBordUserfPoint%(): FEpaisBordUserfPoint = 4: End Function
 
Dernière édition:

Roland_M

XLDnaute Barbatruc
Re : Novice - Erreur de compilation : Else sans If !

bonsoir,

sur mac je sais pas du tout !?
c'est une routine que j'ai faite au départ pour mes propres besoins
maintenant que je suis sur ce formidable forum j'en fais profiter chaque fois !
 

Llyod

XLDnaute Nouveau
Re : Novice - Erreur de compilation : Else sans If !

En tout cas, merci de le partager, j'essayerais ça plus tard dans la soirée :p
J'ai regardé vos différents messages que vous avez postés et je suis tomber sur un sujet concernant les onglets dans les userforms. Je ne connaissait pas cette méthode, pensez-vous qu'elle sera plus facile à mettre en place ou est elle plus complexe ?

Car vu qu'il y a plusieurs tours dans mon tournoi, je fait appel à une succession d'userforms qui font usine à gaz..
 

Roland_M

XLDnaute Barbatruc
Re : Novice - Erreur de compilation : Else sans If !

re

non on gère le onglets sur l'userf comme on gère les onglets feuilles on les sélect c'est tout
après tout est question d'organisation et de rigueur dans les noms donnés aux objets pour s'y retrouver
 

Llyod

XLDnaute Nouveau
Re : Novice - Erreur de compilation : Else sans If !

Enorme !! J'ai pas bien compris la différence entre des pages et des onglets !
Dans mon cas, j'aimerais avoir un nombre de pages/onglets défini et quand on appuie sur le bouton valider, on page au 2 et ça verrouille la 1 !!
 

Discussions similaires

Réponses
6
Affichages
273
Réponses
3
Affichages
550

Statistiques des forums

Discussions
312 391
Messages
2 087 984
Membres
103 690
dernier inscrit
LeDuc