Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: birillo1959 on October 12, 2023, 03:54:41 AM
-
Good morning
I use this macro to insert values into the dro
I have a problem, if I enter the value and press "OK" it's fine, if I press "CANCEL" it comes out and resets the dro, is it possible to modify it?
in the sense that by pressing "CANCEL" it comes out but DOES NOT change the value in the database. Since it is not within my capabilities/expertise, is there anyone who can help me?
Greetings
' TAST ASSE X
Global value As String
Sub Main
'declare variables
Dim Pos As Double
Dim OldDroValue As Double
Dim MinPos As Double
Dim MaxPos As Double
Dim DroNum As Integer
'preset the variables
MinPos = -1000.0
MaxPos = 1000.0
DroNum = 800
'get the actual DRO value
OldDroValue = GetOemDro(DroNum)
'show the virtual keyboard
Call NumericKeyboard(DroNum,MinPos,MaxPos)
'get the new DRO value
Pos = GetOEMDro(DroNum)
End Sub
'TPS 01.12.2017
'numerische Eingabe
Function NumericKeyboard(ByVal DRONum As Integer , ByVal Min As Double , ByVal Max As Double) As Double
Dim title As String
value = "" 'GetOemDRO(DRONum)
title = Header
Speak (" ASSE x") 'Avviso Vocale
Begin Dialog UserDialog1 410,10, 125, 240, "INSERIMENTO VALORI:" , .Enable
Picture 0, 0, 125, 210, "c:\mach3\bitmaps\Ita_Screenset\TASTIERA.bmp"
PushButton 20, 10, 25, 25, "7", .but7
PushButton 50, 10, 25, 25, "8", .but8
PushButton 80, 10, 25, 25, "9", .but9
PushButton 20, 40, 25, 25, "4", .but4
PushButton 50, 40, 25, 25, "5", .but5
PushButton 80, 40, 25, 25, "6", .but6
PushButton 20, 70, 25, 25, "1", .but1
PushButton 50, 70, 25, 25, "2", .but2
PushButton 80, 70, 25, 25, "3", .but3
PushButton 20, 100, 25, 25, ".", .butD
PushButton 50, 100, 25, 25, "0", .but0
PushButton 80, 100, 25, 25, "<-", .butB
PushButton 20, 130, 25, 25, "+/-", .butN
PushButton 50, 130, 25, 25, "00", .butA
PushButton 80, 130, 25, 25, "Del", .butDel
TextBox 20, 160, 85, 18, .FText
PushButton 20, 185, 40, 18,"OK", .OK
CancelButton 65, 185, 40, 18
Text 50, 215, 100, 18," ASSE X"
End Dialog
Dim Dlg1 As UserDialog1
Dlg1.FText = CStr(value)
x = Dialog( Dlg1 )
NumericKeyboard = CDbl(Dlg1.FText)
If CDbl(Dlg1.FText) < Min Then NumericKeyboard = Min
If CDbl(Dlg1.FText) > Max Then NumericKeyboard = Max
SetOEMDro(DRONum,NumericKeyboard)
End Function
Function Enable( ControlID$, Action%, SuppValue%)
Select Case Action%
Case 1
Case 2 'Button wurde gerückt
If ControlID$ = "but0" Then
value = CStr(value) + "0"
DlgText "FText", CStr(value)
Enable =1
Speak ("0") 'Avviso Vocale
End If
If ControlID$ = "but1" Then
value = CStr(value) + "1"
DlgText "FText", CStr(value)
Enable =1
Speak ("1") 'Avviso Vocale
End If
If ControlID$ = "but2" Then
value = CStr(value) + "2"
DlgText "FText", CStr(value)
Enable =1
Speak ("2") 'Avviso Vocale
End If
If ControlID$ = "but3" Then
value = CStr(value) + "3"
DlgText "FText", CStr(value)
Enable =1
Speak ("3") 'Avviso Vocale
End If
If ControlID$ = "but4" Then
value = CStr(value) + "4"
DlgText "FText", CStr(value)
Enable =1
Speak ("4") 'Avviso Vocale
End If
If ControlID$ = "but5" Then
value = CStr(value) + "5"
DlgText "FText", CStr(value)
Enable =1
Speak ("5") 'Avviso Vocale
End If
If ControlID$ = "but6" Then
value = CStr(value) + "6"
DlgText "FText", CStr(value)
Enable =1
Speak ("6") 'Avviso Vocale
End If
If ControlID$ = "but7" Then
value = CStr(value) + "7"
DlgText "FText", CStr(value)
Enable =1
Speak ("7") 'Avviso Vocale
End If
If ControlID$ = "but8" Then
value = CStr(value) + "8"
DlgText "FText", CStr(value)
Enable =1
Speak ("8") 'Avviso Vocale
End If
If ControlID$ = "but9" Then
value = CStr(value) + "9"
DlgText "FText", CStr(value)
Enable =1
Speak ("9") 'Avviso Vocale
End If
If ControlID$ = "butA" Then
value = CStr(value) + "00"
DlgText "FText", CStr(value)
Enable =1
Speak ("0 0") 'Avviso Vocale
End If
If ControlID$ = "butD" Then
If InStr(1,value,".") = 0 Then
value = CStr(value) + "."
DlgText "FText", CStr(value)
Enable =1
Speak ("punto") 'Avviso Vocale
End If
End If
If ControlID$ = "butB" Then
value = Left(value,Len(value)-1)
DlgText "FText", CStr(value)
Enable =1
Speak ("indietro") 'Avviso Vocale
End If
If ControlID$ = "butN" Then
If Left(value,1) = "-" Then
value = "+" + CStr(Right(value,Len(value)-1))
Speak ("piu' ") 'Avviso Vocale
Else
If Left(value,1) = "+" Then
value = "-" + CStr(Right(value,Len(value)-1))
Else
value = "-" + CStr(value)
Speak ("meno ") 'Avviso Vocale
End If
End If
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "butDel" Then
value = ""
DlgText "FText", CStr(value)
Enable =1
Speak ("cancella ") 'Avviso Vocale
End If
If ControlID$ = "OK" Then
Enable = -1
End If
Case 3 'Text verändert
'MsgBox Dlg1.FText
Case Else
End Select
'Wert zurückgeben
If Enable = -1 Then
Enable = value
End If
End Function
-
' TAST ASSE X
Global value As String
Global CanButtonpressed As Boolean
Sub Main
'declare variables
Dim Pos As Double
Dim OldDroValue As Double
Dim MinPos As Double
Dim MaxPos As Double
Dim DroNum As Integer
'preset the variables
MinPos = -1000.0
MaxPos = 1000.0
DroNum = 800
'get the actual DRO value
OldDroValue = GetOemDro(DroNum)
CanButtonpressed = false
'show the virtual keyboard
Call NumericKeyboard(DroNum,MinPos,MaxPos)
'get the new DRO value
Pos = GetOEMDro(DroNum)
End Sub
'TPS 01.12.2017
'numerische Eingabe
Function NumericKeyboard(ByVal DRONum As Integer , ByVal Min As Double , ByVal Max As Double) As Double
Dim title As String
value = "" 'GetOemDRO(DRONum)
title = Header
Speak (" ASSE x") 'Avviso Vocale
Begin Dialog UserDialog1 410,10, 125, 240, "INSERIMENTO VALORI:" , .Enable
Picture 0, 0, 125, 210, "c:\mach3\bitmaps\Ita_Screenset\TASTIERA.bmp"
PushButton 20, 10, 25, 25, "7", .but7
PushButton 50, 10, 25, 25, "8", .but8
PushButton 80, 10, 25, 25, "9", .but9
PushButton 20, 40, 25, 25, "4", .but4
PushButton 50, 40, 25, 25, "5", .but5
PushButton 80, 40, 25, 25, "6", .but6
PushButton 20, 70, 25, 25, "1", .but1
PushButton 50, 70, 25, 25, "2", .but2
PushButton 80, 70, 25, 25, "3", .but3
PushButton 20, 100, 25, 25, ".", .butD
PushButton 50, 100, 25, 25, "0", .but0
PushButton 80, 100, 25, 25, "<-", .butB
PushButton 20, 130, 25, 25, "+/-", .butN
PushButton 50, 130, 25, 25, "00", .butA
PushButton 80, 130, 25, 25, "Del", .butDel
PushButton 20, 185, 40, 18,"OK", .OK
PushButton 65, 185, 40, 18,"Cancel", .CAN
TextBox 20, 160, 85, 18, .FText
Text 50, 215, 100, 18," ASSE X"
End Dialog
Dim Dlg1 As UserDialog1
Dlg1.FText = CStr(value)
x = Dialog( Dlg1 )
NumericKeyboard = CDbl(Dlg1.FText)
If CDbl(Dlg1.FText) < Min Then NumericKeyboard = Min
If CDbl(Dlg1.FText) > Max Then NumericKeyboard = Max
If CanButtonpressed = false Then
SetOEMDro(DRONum,NumericKeyboard)
End If
End Function
Function Enable( ControlID$, Action%, SuppValue%)
Select Case Action%
Case 1
Case 2 'Button wurde gerückt
If ControlID$ = "but0" Then
value = CStr(value) + "0"
DlgText "FText", CStr(value)
Enable =1
Speak ("0") 'Avviso Vocale
End If
If ControlID$ = "but1" Then
value = CStr(value) + "1"
DlgText "FText", CStr(value)
Enable =1
Speak ("1") 'Avviso Vocale
End If
If ControlID$ = "but2" Then
value = CStr(value) + "2"
DlgText "FText", CStr(value)
Enable =1
Speak ("2") 'Avviso Vocale
End If
If ControlID$ = "but3" Then
value = CStr(value) + "3"
DlgText "FText", CStr(value)
Enable =1
Speak ("3") 'Avviso Vocale
End If
If ControlID$ = "but4" Then
value = CStr(value) + "4"
DlgText "FText", CStr(value)
Enable =1
Speak ("4") 'Avviso Vocale
End If
If ControlID$ = "but5" Then
value = CStr(value) + "5"
DlgText "FText", CStr(value)
Enable =1
Speak ("5") 'Avviso Vocale
End If
If ControlID$ = "but6" Then
value = CStr(value) + "6"
DlgText "FText", CStr(value)
Enable =1
Speak ("6") 'Avviso Vocale
End If
If ControlID$ = "but7" Then
value = CStr(value) + "7"
DlgText "FText", CStr(value)
Enable =1
Speak ("7") 'Avviso Vocale
End If
If ControlID$ = "but8" Then
value = CStr(value) + "8"
DlgText "FText", CStr(value)
Enable =1
Speak ("8") 'Avviso Vocale
End If
If ControlID$ = "but9" Then
value = CStr(value) + "9"
DlgText "FText", CStr(value)
Enable =1
Speak ("9") 'Avviso Vocale
End If
If ControlID$ = "butA" Then
value = CStr(value) + "00"
DlgText "FText", CStr(value)
Enable =1
Speak ("0 0") 'Avviso Vocale
End If
If ControlID$ = "butD" Then
If InStr(1,value,".") = 0 Then
value = CStr(value) + "."
DlgText "FText", CStr(value)
Enable =1
Speak ("punto") 'Avviso Vocale
End If
End If
If ControlID$ = "butB" Then
value = Left(value,Len(value)-1)
DlgText "FText", CStr(value)
Enable =1
Speak ("indietro") 'Avviso Vocale
End If
If ControlID$ = "butN" Then
If Left(value,1) = "-" Then
value = "+" + CStr(Right(value,Len(value)-1))
Speak ("piu' ") 'Avviso Vocale
Else
If Left(value,1) = "+" Then
value = "-" + CStr(Right(value,Len(value)-1))
Else
value = "-" + CStr(value)
Speak ("meno ") 'Avviso Vocale
End If
End If
DlgText "FText", CStr(value)
Enable =1
End If
If ControlID$ = "butDel" Then
value = ""
DlgText "FText", CStr(value)
Enable =1
Speak ("cancella ") 'Avviso Vocale
End If
If ControlID$ = "OK" Then
Enable = -1
End If
If ControlID$ = "CAN" Then
CanButtonpressed = true
Enable = -1
End If
Case 3 'Text verändert
'MsgBox Dlg1.FText
Case Else
End Select
'Wert zurückgeben
If Enable = -1 Then
Enable = value
End If
End Function
-
TPS thanks for your help, once again you solved my problem !!!!!!!!!! works well.
Greetings