Bitte testen und konstr. kritisieren :)

Programmierung unter AOO/LO (StarBasic, Python, Java, ...)

Moderator: Moderatoren

Benutzeravatar
opiWahn
***
Beiträge: 91
Registriert: Mo, 21.03.2011 15:47
Wohnort: zw. KL und NW

Bitte testen und konstr. kritisieren :)

Beitrag von opiWahn »

Hallo,

ich hab mich entschlossen das Tool (meine neverending story) mal zum Testen und Kritisieren einzustellen.
Die Zip-Datei enthält die nötigen Verzeichnisse und odt-Dateien und ist auf LW C: festgelegt.
Also ggf. im Code nach Wahl ändern.
Die DB ist wg. der Größe (29 MB) nicht dabei, deswegen wird diese Funktion nicht ihren Dienst verrichten.
Das obere Drittel läßt sich von Hand füllen, in dem man oben rechts "Edit" aktiviert.
Es gibt noch ne Menge Bugs und Dinge, die man verbessern kann, ich hab das Thema Ooo-Basic erst vor 6 Wochen erstmalig angefasst.
Interessant/wichtig wäre z.B. auch die Möglichkeit auf der Subform die Checkboxen mit den jeweils darüber liegenden Options zu steuern.

o# = checkboxen sind deaktiviert (evtl. grau)
o! = checkboxen sind aktiviert (evtl. rot oder umrahmt bis min. eine ausgewählt wurde)

Wie an anderer Stelle schon angefragt versagt seit ein paar Tagen das Hinzufügen der externen Datei ihren Dienst und ich hab kein Schimmer wieso, da ich in diesem Bereich nichts geändert habe und das ganze schon eine ganze Zeit lang funktionierte. :)

Ich freu mich über euere Hilfe und die sicherlich konstruktive Kritiken
Frohe Ostern ...
Dateianhänge
xyz.zip
(86.54 KiB) 69-mal heruntergeladen
Grüße
opiWahn
hol.sten
******
Beiträge: 871
Registriert: Fr, 18.11.2005 21:21

Re: Bitte testen und konstr. kritisieren :)

Beitrag von hol.sten »

opiWahn hat geschrieben:das Tool (meine neverending story) mal zum Testen und Kritisieren einzustellen.
Das zu deinem Tool noch nicht allzu viele Rückmeldungen abgegeben wurden könnte an deine mageren Beschreibung liegen, was es hier zu testen gibt.
Benutzeravatar
opiWahn
***
Beiträge: 91
Registriert: Mo, 21.03.2011 15:47
Wohnort: zw. KL und NW

Re: Bitte testen und konstr. kritisieren :)

Beitrag von opiWahn »

Hallo hol.sten,

natürlich hast du recht - hier noch ein paar Infos:
Das ganze ist für ein Metallbauunternehmen gedacht, welche Tore, Rampen u.ä. montiert, repariert, prüft u.s.w.
Die Grunddaten der Auftragsform werden im Normalfall aus einer DB gezogen, alternativ erfolgt eine freie Eingabe der Grunddaten über die "Edit"Checkbox.
Die Optionsgruppen sind Pflicht und lösen ggf. das Ausfüllpflicht von Std.nachweis oder Bestellung aus.
Vor dem Speichern als ODT o. PDF (unter dem Namen des jeweiligen Kunden" sollen die Pflichtfelder geprüft werden - erst dann ist ein Speichern möglich.
Dieses elektronische Einzelteil (also nur die erste Seite) bekommt der Techniker auf das Tablet.
Vor Ort kann er dann verschiedene Berichte (TT o. VT) anfügen und ausfüllen. Die Grunddaten werden von Seite 1 übernommen.
Idealerweise müßte eine Prüfung nach Pflichtfelder auch dort stattfinden unter den gleichen Bedingungen was z.B. das Speichern betrifft.
Der Code für die Auftragsform sieht bislang so aus (ggf. einfach ersetzen):

Code: Alles auswählen


'  *********** mainForm1 ***********

' Database
Dim oContext As Object, oDB As Object, oConnection As Object, oQueryRes As Object
Dim DBName$, SQL$
Dim vStatement

' FormObjects
Dim oForm As Object
Dim aField(16), aText(83), aOrder(23), aWorkHrs(83)
Dim aOpt1(), aOpt2(), aOpt3(), aOpt4()
Dim TempText$
Dim s1_1$, s1_2$, s2_1$, s2_2$, s3_1$, s3_2$, s4_1$, s4_2$

'clearForm
Dim n
Dim aFail(3), aGrpFail(3), aTxtField(40), aNumField(83), aAllField(83)

' ErrorProof
Dim vGrpFail
Dim errormsg1$
Dim iError As Integer

' save odt/PDF 
Dim datname$, path$, extension$, odturl$, pdfurl$

' addForm
'dim document As Object, dispatcher As Object

' fillUform
Dim oMainForm As Object, oSubForm As Object


'--------------------------------------------------------------------------------------------- Baustelle!
Sub clearForm

aFail() = Array ("grp1_fail","grp2_fail","grp3_fail","grp4_fail")
aTxtField() = Array ("txt_oName", "txt_oTitel", "txt_oStrasse", "txt_oOrt", "txt_oPersAnrede", "txt_oTelefon", "txt_oVerladeStNr", "txt_oGeraeteNr", _
	"txt_rName", "txt_rTitel", "txt_rStrasse", "txt_rOrt", "txt_oUAuftrBest", "txt_oUAngebNr", "txt_oUBestNr", "txt_oIAuftrNr", "txt_oLangtext",_
	"txt_Name1","txt_Name2","txt_Name3","txt_Name4","txt_Name5","txt_Name6","txt_Name7","txt_Name8", _
	"txt_ArtNr1","txt_ArtBez1","txt_ArtNr2","txt_ArtBez2","txt_ArtNr3","txt_ArtBez3","txt_ArtNr4","txt_ArtBez4","txt_ArtNr5","txt_ArtBez5", _
	"txt_ArtNr6","txt_ArtBez6","txt_ArtNr7","txt_ArtBez7","txt_ArtNr8","txt_ArtBez8")
	
aNumField() = Array ("num_StdMoName1","num_StdDiName1","num_StdMiName1","num_StdDoName1","num_StdFrName1","num_StdSaName1","num_StdSoName1","num_StdAzGesName1","num_StdFzGesName1", _
	"num_StdMoName2","num_StdDiName2","num_StdMiName2","num_StdDoName2","num_StdFrName2","num_StdSaName2","num_StdSoName2","num_StdAzGesName2","num_StdFzGesName2", _
	"num_StdMoName3","num_StdDiName3","num_StdMiName3","num_StdDoName3","num_StdFrName3","num_StdSaName3","num_StdSoName3","num_StdAzGesName3","num_StdFzGesName3", _
	"num_StdMoName4","num_StdDiName4","num_StdMiName4","num_StdDoName4","num_StdFrName4","num_StdSaName4","num_StdSoName4","num_StdAzGesName4","num_StdFzGesName4", _
	"num_StdMoName5","num_StdDiName5","num_StdMiName5","num_StdDoName5","num_StdFrName5","num_StdSaName5","num_StdSoName5","num_StdAzGesName5","num_StdFzGesName5", _
	"num_StdMoName6","num_StdDiName6","num_StdMiName6","num_StdDoName6","num_StdFrName6","num_StdSaName6","num_StdSoName6","num_StdAzGesName6","num_StdFzGesName6", _
	"num_StdMoName7","num_StdDiName7","num_StdMiName7","num_StdDoName7","num_StdFrName7","num_StdSaName7","num_StdSoName7","num_StdAzGesName7","num_StdFzGesName7", _
	"num_StdMoName8","num_StdDiName8","num_StdMiName8","num_StdDoName8","num_StdFrName8","num_StdSaName8","num_StdSoName8","num_StdAzGesName8","num_StdFzGesName8", _
	"num_KM","num_U25","num_U50","num_U100","num_ArtAnz1","num_ArtAnz2","num_ArtAnz3","num_ArtAnz4","num_ArtAnz5","num_ArtAnz6","num_ArtAnz7","num_ArtAnz8")
	
	With ThisComponent.DrawPage.Forms.GetByName("mainForm1")
		For n = 0 to .Count - 1
			On Error Resume Next
			If Right(.GetByIndex(n).ServiceName, 11) = "RadioButton" Then
				.GetByIndex(n).State = 0
			End If
		Next n
	End With
		
	oForm = thisComponent.drawpage.forms.getbyindex(0)		
		For i = 0 to 3
			aGrpFail(i) = oForm.getByName(aFail(i))
			aGrpFail(i).Text=""
		Next i
		
		For i = 0 to 40
			aAllField(i) = oForm.getByName(aTxtField(i))
			aAllField(i).Text=""
			aAllField(i).ReadOnly = true
			aAllField(i).BackgroundColor = RGB(255,255,255)
		Next i
		
		For i = 0 to 83
			aAllField(i) = oForm.getByName(aNumField(i))
			aAllField(i).reset()
			aAllField(i).ReadOnly = true
			aAllField(i).BackgroundColor = RGB(255,255,255)
		Next i
			
end Sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub Value_ANr

clearForm  

	oANr = inputBox ("Auftragsnummer","Eingabe erforderlich","Bitte Auftragsnummer eingeben")
	oForm = thisComponent.drawpage.forms.getbyindex(0)
	aField() = Array ("txt_oName", "txt_oTitel", "txt_oStrasse", "txt_oOrt", "txt_oPersAnrede", "txt_oTelefon", _
	"txt_rName", "txt_rTitel", "txt_rStrasse", "txt_rOrt", "txt_oLangtext")
	
		for i = 0 to 10
			aText(i) = oForm.getByName(aField(i))
		next i
			
   	DBName = "REPARATUR"
	oContext = createUnoService("com.sun.star.sdb.DatabaseContext")
	oDB = oContext.GetByName (DBName)
	oConnection = oDB.GetConnection ("","")
	Sql = "SELECT `objekt_name`,`objekt_titel`,`objekt_strasse`,`objekt_ort`,`objekt_persanrede`,`objekt_telefon`,`rechnung_name`,`rechnung_titel`,`rechnung_strasse`,`rechnung_ort`,`langtext` FROM `REPARATUR` WHERE `key` = '"+oANr+"';"	
		
	vStatement = oConnection.CreateStatement
	oQueryRes = vStatement.ExecuteQuery(SQL)
		
		for i = 0 to 10
			aText(i).text = trim(oQueryRes.GetString(i+1))
			if i = 10 then
				TempText = trim(oQueryRes.GetString(i+1))
				aText(i).text = Replace(TempText, Chr$(10)& Chr$(13), "")
			end if
		next i
				
	oConnection.Close()
			
End Sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub freeEdit

	oForm = thisComponent.drawpage.forms.getbyindex(0)
	oEdit = oForm.getByName("chk_edit")
	aField() = Array ("txt_oName", "txt_oTitel", "txt_oStrasse", "txt_oOrt", "txt_oPersAnrede", "txt_oTelefon", "txt_oVerladeStNr", "txt_oGeraeteNr", _
	"txt_rName", "txt_rTitel", "txt_rStrasse", "txt_rOrt", "txt_oUAuftrBest", "txt_oUAngebNr", "txt_oUBestNr", "txt_oIAuftrNr", "txt_oLangtext")
	
		for i = 0 to 16
			aText(i) = oForm.getByName(aField(i))
		next i
	
		if oEdit.State = 1 then
			for i = 0 to 16
				aText(i).ReadOnly = false
				aText(i).BackgroundColor = RGB(200,2000,200)			
			next i
		MsgBox "Alle grauen Felder können nun frei" & CHR$(10) & " geändert oder ergänzt werden", 0, "Hinweis!" 
		else
			for i = 0 to 16
				aText(i).ReadOnly = true
				aText(i).BackgroundColor = RGB(255,255,255)
			next i	
		end if
		
end Sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub proofOptGrp1
   	iError = 0
	oForm = thisComponent.drawpage.forms.getbyindex(0)
	oForm.getGroupByName("opt_grp1", aOpt1)
	vGrpFail = oForm.getbyName("grp1_fail")
	errormsg1 = "In der markierten Optionsgruppe liegt ein Fehler vor" & CHR$(10) & "BITTE PRÜFEN!"
	bSelected = False
	
   	For i = LBound(aOpt1) to UBound(aOpt1)
      thisElement = aOpt1(i)
      If thisElement.ServiceName = "stardiv.one.form.component.RadioButton" Then
         If thisElement.State Then
            bSelected = True
            s1_1 = thisElement.Name 
            s1_2 = thisElement.Label
            Exit For
         End If
      End If
   	Next i
   	If bSelected Then
   	  vGrpFail.text = ""
   	Else
   	  vGrpFail.text = "!"
   	  MsgBox errormsg1, 0+48, "Achtung"
   	  iError = 1
   	End If
   	
end sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub proofOptGrp2

	oForm = thisComponent.drawpage.forms.getbyindex(0)
	oForm.getGroupByName("opt_grp2", aOpt2)
	vGrpFail = oForm.getbyName("grp2_fail")
	aWorkHrs() = Array ("txt_Name1","num_StdMoName1","num_StdDiName1","num_StdMiName1","num_StdDoName1", _
	"num_StdFrName1","num_StdSaName1","num_StdSoName1","num_StdAzGesName1","num_StdFzGesName1", _
	"txt_Name2","num_StdMoName2","num_StdDiName2","num_StdMiName2","num_StdDoName2","num_StdFrName2", _
	"num_StdSaName2","num_StdSoName2","num_StdAzGesName2","num_StdFzGesName2", _
	"txt_Name3","num_StdMoName3","num_StdDiName3","num_StdMiName3","num_StdDoName3","num_StdFrName3", _
	"num_StdSaName3","num_StdSoName3","num_StdAzGesName3","num_StdFzGesName3", _
	"txt_Name4","num_StdMoName4","num_StdDiName4","num_StdMiName4","num_StdDoName4","num_StdFrName4", _
	"num_StdSaName4","num_StdSoName4","num_StdAzGesName4","num_StdFzGesName4", _
	"txt_Name5","num_StdMoName5","num_StdDiName5","num_StdMiName5","num_StdDoName5","num_StdFrName5", _
	"num_StdSaName5","num_StdSoName5","num_StdAzGesName5","num_StdFzGesName5", _
	"txt_Name6","num_StdMoName6","num_StdDiName6","num_StdMiName6","num_StdDoName6","num_StdFrName6", _
	"num_StdSaName6","num_StdSoName6","num_StdAzGesName6","num_StdFzGesName6", _
	"txt_Name7","num_StdMoName7","num_StdDiName7","num_StdMiName7","num_StdDoName7","num_StdFrName7", _
	"num_StdSaName7","num_StdSoName7","num_StdAzGesName7","num_StdFzGesName7", _
	"txt_Name8","num_StdMoName8","num_StdDiName8","num_StdMiName8","num_StdDoName8","num_StdFrName8", _
	"num_StdSaName8","num_StdSoName8","num_StdAzGesName8","num_StdFzGesName8", _
	"num_KM","num_U25","num_U50","num_U100")
	errormsg1 = "In der markierten Optionsgruppe liegt ein Fehler vor" & CHR$(10) & "BITTE PRÜFEN!"
	bSelected = False
	
   	For i = LBound(aOpt2) to UBound(aOpt2)
      thisElement = aOpt2(i)
      If thisElement.ServiceName = "stardiv.one.form.component.RadioButton" Then
         If thisElement.State Then
            bSelected = True
            s2_1 = thisElement.Name 
            s2_2 = thisElement.Label
            Exit For
         End If
      End If
   	Next i
   	
   	If bSelected And s2_2 = "Lohnnachweis" Then
   	  vGrpFail.text = ""
   	  MsgBox "Einträge in den roten Feldern" & CHR$(10) & "sind zwingend erforderlich", 0+48, "Achtung"
   	 
		for i = 0 to 83
			aText(i) = oForm.getByName(aWorkHrs(i))
			aText(i).ReadOnly = false
			aText(i).BackgroundColor = RGB(255,119,119)	
		next i
	
   	Elseif bSelected And s2_2 = "zum Festpreis" Then
   	  vGrpFail.text = ""
   	  
   	  	for i = 0 to 83
   	  		aText(i) = oForm.getByName(aWorkHrs(i))
			aText(i).ReadOnly = true
			aText(i).BackgroundColor = RGB(255,255,255)
		next i
   	
   	Else
   	  vGrpFail.text = "!"
   	  MsgBox errormsg1, 0+48, "Achtung"
   	  iError = iError + 1
   	End If
   	
end sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub proofOptGrp3

	oForm = thisComponent.drawpage.forms.getbyindex(0)
	oForm.getGroupByName("opt_grp3", aOpt3)
	vGrpFail = oForm.getbyName("grp3_fail")
	errormsg1 = "In der markierten Optionsgruppe liegt ein Fehler vor" & CHR$(10) & "BITTE PRÜFEN!"
	bSelected = False
	
   	For i = LBound(aOpt3) to UBound(aOpt3)
      thisElement = aOpt3(i)
      If thisElement.ServiceName = "stardiv.one.form.component.RadioButton" Then
         If thisElement.State Then
            bSelected = True
            s3_1 = thisElement.Name 
            s3_2 = thisElement.Label
            Exit For
         End If
      End If
   	Next i
   	If bSelected Then
   	  vGrpFail.text = ""
   	Else
   	  vGrpFail.text = "!"
   	  MsgBox errormsg1, 0+48, "Achtung"
   	  iError = iError + 1
   	End If
   	
end sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub proofOptGrp4

	oForm = thisComponent.drawpage.forms.getbyindex(0)
	oForm.getGroupByName("opt_grp4", aOpt4)
	vGrpFail = oForm.getbyName("grp4_fail")
	aOrder() = Array ("txt_ArtNr1","txt_ArtBez1","num_ArtAnz1","txt_ArtNr2","txt_ArtBez2","num_ArtAnz2","txt_ArtNr3","txt_ArtBez3","num_ArtAnz3", _
	"txt_ArtNr4","txt_ArtBez4","num_ArtAnz4","txt_ArtNr5","txt_ArtBez5","num_ArtAnz5","txt_ArtNr6","txt_ArtBez6","num_ArtAnz6", _
	"txt_ArtNr7","txt_ArtBez7","num_ArtAnz7","txt_ArtNr8","txt_ArtBez8","num_ArtAnz8")
	errormsg1 = "In der markierten Optionsgruppe liegt ein Fehler vor" & CHR$(10) & "BITTE PRÜFEN!"	
	bSelected = False
	
   	For i = LBound(aOpt4) to UBound(aOpt4)
      thisElement = aOpt4(i)
      If thisElement.ServiceName = "stardiv.one.form.component.RadioButton" Then
         If thisElement.State Then
            bSelected = True
            s4_1 = thisElement.Name 
            s4_2 = thisElement.Label
            Exit For
         End If
      End If
   	Next i
   	
   	If bSelected And s4_2 = "Ja" Then
   	  vGrpFail.text = ""
   	  MsgBox  "Einträge in den roten Feldern" & CHR$(10) & "sind zwingend erforderlich", 0+48, "Achtung"
   	 
		for i = 0 to 23
			aText(i) = oForm.getByName(aOrder(i))
			aText(i).ReadOnly = false
			aText(i).BackgroundColor = RGB(255,119,119)	
		next i
			
   	Elseif bSelected And s4_2 = "Nein" Then
   	  vGrpFail.text = ""
   	  
   	  	for i = 0 to 23
   	  		aText(i) = oForm.getByName(aOrder(i))
			aText(i).ReadOnly = true
			aText(i).BackgroundColor = RGB(255,255,255)
		next i
			
   	Else  
   	  vGrpFail.text = "!"
      MsgBox errormsg1, 0+48, "Achtung"
      iError = iError + 1
   	End If
   	
end sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub proofAllOptGrp
	
	proofOptGrp1
	proofOptGrp2
	proofOptGrp3
	proofOptGrp4
		
End Sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub Save_as_ODT

proofAllOptGrp
msgbox iError

	if iError > 0 then
		MsgBox "Sie haben noch "& iError &" Fehler zu beheben", 0+48, "Achtung"
'		 Sub verlassen				
	else	
	oform = thisComponent.drawpage.forms.getbyindex(0)
	aText = oForm.getByName("txt_oName")

		if aText.text = "" then
			datname = "blanc"
		else
			datname = aText.text
		end if
	path = "C:/xyz/Auftraege/"
	extension = ".odt"
	odturl = "file:///" + path + datname + extension
	thisComponent.storeToURL(odturl, Array())
	
clearForm
		
End Sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub Save_as_PDF

proofAllOptGrp
msgbox iError

	if iError > 0 then
		MsgBox "Sie haben noch "& iError &" Fehler zu beheben", 0+48, "Achtung"
'		 Sub verlassen			
	else
	oform = thisComponent.drawpage.forms.getbyindex(0)
	aText = oForm.getByName("txt_oName")
		if aText.text = "" then
			datname = "blanc"
		else
			datname = aText.text
		end if
	path = "C:/yxz/Auftraege/PDF/"
	extension = ".pdf"
	pdfurl = "file:///" + path + datname + extension
	dim pdfProperties(1) as new com.sun.star.beans.PropertyValue
	pdfProperties(0).Name = "FilterName"
	pdfProperties(0).Value = "writer_pdf_Export"
	thisComponent.storeToURL(pdfurl, pdfProperties())
	
clearForm
	
End Sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub addPruefForm_TT

  oViewCursor = thisComponent.getCurrentController.getViewCursor
  oViewCursor.jumpToLastPage(true)
  oViewCursor.jumpToEndofPage(true)
  
  Dim args2(0) as New com.sun.star.beans.PropertyValue
  oText = thisComponent.getText()   
  oTextCursor = oText.createTextCursor
  oTextCursor.gotoEnd(False)
  oTextCursor.BreakType = com.sun.star.style.BreakType.PAGE_AFTER
  oText.insertControlCharacter(oTextCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
  sInhalt="file:///C:/xyz/xtFormulare/subForm_TT.odt"
  filetoinsert=converttourl(sInhalt)
  oTextCursor.InsertDocumentFromUrl(FileToInsert,args2())

fillUform

End Sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub addPruefForm_VT

  oViewCursor = thisComponent.getCurrentController.getViewCursor
  oViewCursor.jumpToLastPage(true)
  oViewCursor.jumpToEndofPage(true)
  
  Dim args2(0) as New com.sun.star.beans.PropertyValue
  oText = thisComponent.getText()   
  oTextCursor = oText.createTextCursor
  oTextCursor.gotoEnd(False)
  oTextCursor.BreakType = com.sun.star.style.BreakType.PAGE_AFTER
  oText.insertControlCharacter(oTextCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
  sInhalt="file:///C:/xyz/xtFormulare/subForm_VT.odt"
  filetoinsert=converttourl(sInhalt)
  oTextCursor.InsertDocumentFromUrl(FileToInsert,args2())

fillUform

End Sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub fillUform

	oMainForm = thisComponent.Drawpage.Forms.getByIndex(0)
	oSubForm = thisComponent.Drawpage.Forms.getByIndex(thisComponent.Drawpage.Forms.Count - 1)
	aField() = Array ("txt_oName", "txt_oTelefon","txt_oStrasse", "txt_oOrt")
	
		for i = 0 to 3
		
			aText(i) = oSubForm.getByName(aField(i))
			
				If oMainForm.hasByName(aText(i).Name) Then
  					aText(i).Text = oMainForm.getByName(aText(i).Name).Text
  				else
  					aText(i).Text = "keine Daten"
				End If	
			
		next i
		
End sub

Exemplarisch hier der Code für eine Subform (TT). Hier funktioniert die Prüfung jedoch noch auf dieser Seite und schlägt nopch nicht auf die Hauptform durch.

Code: Alles auswählen

'  *********** subForm_TT ***********

' FormObjects
Dim oForm As Object
Dim aField(25), aText(25)
Dim aOpt1(), aOpt2(), aOpt3()
Dim s1_1$, s1_2$, s2_1$, s2_2$, s3_1$, s3_2$

' clearForm
Dim n
Dim aFail(2), aGrpFail(2)

' ErrorProof
Dim vGrpFail
Dim errormsg1$

'--------------------------------------------------------------------------------------------- Baustelle!
Sub clearForm

aFail() = Array ("grp1_fail","grp2_fail","grp3_fail")

	With ThisComponent.DrawPage.Forms.GetByName("subForm_TT")
		For n = 0 to .Count - 1
			On Error Resume Next
			If Right(.GetByIndex(n).ServiceName, 11) = "RadioButton" Then
				.GetByIndex(n).State = 0
			End If
		Next n
	End With
		
	oForm = thisComponent.drawpage.forms.getbyindex(0)		
		For i = 0 to 2
			aGrpFail(i) = oForm.getByName(aFail(i))
			aGrpFail(i).Text=""
		Next i
		
End Sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub proofOptGrp1

	oForm = thisComponent.drawpage.forms.getbyindex(0)
	oForm.getGroupByName("opt_grp1", aOpt1)
	vGrpFail = oForm.getbyName("grp1_fail")
	errormsg1 = "In der markierten Optionsgruppe liegt ein Fehler vor" & CHR$(10) & "BITTE PRÜFEN!"
	bSelected = False
	
   	For i = LBound(aOpt1) to UBound(aOpt1)
      thisElement = aOpt1(i)
      If thisElement.ServiceName = "stardiv.one.form.component.RadioButton" Then
         If thisElement.State Then
            bSelected = True
            s1_1 = thisElement.Name 
            s1_2 = thisElement.Label
            Exit For
         End If
      End If
   	Next i
   	
   	If bSelected Then
   	  vGrpFail.text = ""
   	Else
   	  vGrpFail.text = "!"
   	  MsgBox errormsg1, 0+48, "Achtung"
   	End If
   	
end sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub proofOptGrp2

	oForm = thisComponent.drawpage.forms.getbyindex(0)
	oForm.getGroupByName("opt_grp2", aOpt2)
	vGrpFail = oForm.getbyName("grp2_fail")
	errormsg1 = "In der markierten Optionsgruppe liegt ein Fehler vor" & CHR$(10) & "BITTE PRÜFEN!"
	bSelected = False
	
   	For i = LBound(aOpt2) to UBound(aOpt2)
      thisElement = aOpt2(i)
      If thisElement.ServiceName = "stardiv.one.form.component.RadioButton" Then
         If thisElement.State Then
            bSelected = True
            s2_1 = thisElement.Name 
            s2_2 = thisElement.Label
            Exit For
         End If
      End If
   	Next i
   	
   	If bSelected And s2_2 = "!" Then
   	  vGrpFail.text = ""
   	  MsgBox "Einträge in den folgenden Feldern" & CHR$(10) & "sind zwingend erforderlich", 0+48, "Achtung"
   	 	
   	Elseif bSelected And s2_2 = "#" Then
   	  vGrpFail.text = ""
   	  
   	Else
   	  vGrpFail.text = "!"
   	  MsgBox errormsg1, 0+48, "Achtung"
   	End If
   	
end sub


'--------------------------------------------------------------------------------------------- funktioniert
Sub proofOptGrp3

	oForm = thisComponent.drawpage.forms.getbyindex(0)
	oForm.getGroupByName("opt_grp3", aOpt3)
	vGrpFail = oForm.getbyName("grp3_fail")
	errormsg1 = "In der markierten Optionsgruppe liegt ein Fehler vor" & CHR$(10) & "BITTE PRÜFEN!"
	bSelected = False
	
   	For i = LBound(aOpt3) to UBound(aOpt3)
      thisElement = aOpt3(i)
      If thisElement.ServiceName = "stardiv.one.form.component.RadioButton" Then
         If thisElement.State Then
            bSelected = True
            s3_1 = thisElement.Name 
            s3_2 = thisElement.Label
            Exit For
         End If
      End If
   	Next i
   	
   	If bSelected And s3_2 = "!" Then
   	  vGrpFail.text = ""
   	  MsgBox "Einträge in den folgenden Feldern" & CHR$(10) & "sind zwingend erforderlich", 0+48, "Achtung"
   	 	
   	Elseif bSelected And s3_2 = "#" Then
   	  vGrpFail.text = ""
   	  
   	Else
   	  vGrpFail.text = "!"
   	  MsgBox errormsg1, 0+48, "Achtung"
   	End If
   	
end sub

'--------------------------------------------------------------------------------------------- funktioniert
Sub proofAllOptGrp
	
	proofOptGrp1
	proofOptGrp2
	proofOptGrp3
	
End Sub
Ich freu mich püber jede Hilfe die ich bekommen kann :)
Grüße
opiWahn
Antworten