mardi 1 novembre 2016

Random letter and value Powerpoint VBA

I'm trying to obtain a random generated output with this kind of options:

Firstly a letter which could be R or L Secondly a number that could only be 15, 30, 45 or 60.

For example an output could be R45 or L15. All this should be generated randomly every time the slide is opened.

I tried with this code but without results, no output appears in the label. Can someone give me a hint?

signA = "R"
signB = "L"
cont = Int(Rnd * 100) + 1
Angle = Int(Rnd * 120) + 1

valore = cont Mod 2
If valore = 0 Then
If Angle <= 30 Then
    vardec = "15"
    var = signA & vardec
Else
    If Angle <= 60 Then
        vardec = "30"
        var = signA & vardec
    Else
        If Angle <= 90 Then
            vardec = "45"
            var = signA & vardec
        Else
            vardec = "60"
            var = signA & vardec
        End If
    End If
End If
Else
 If Angle <= 30 Then
    vardec = "15"
    var = signA & vardec
Else
    If Angle <= 60 Then
        vardec = "30"
        var = signA & vardec
    Else
        If Angle <= 90 Then
            vardec = "45"
            var = signA & vardec
        Else
            vardec = "60"
            var = signA & vardec
        End If
    End If
End If
End If
ActivePresentation.Slides(4).Shapes("Label2").OLEFormat.Object.Caption = CStr(var)




Aucun commentaire:

Enregistrer un commentaire