ich habe eine Dialog mit Optionsfeldern. Beim Bearbeiten des Dialogs setze ich ein Optionsfeld auf "ausgewählt".
Wenn ich nun den Dialog starte und ein beliebiges Feld auswähle, wird mir mit "getAuswahl" nicht das ausgeählte, sondern immer(!) das voreingestellte Optionsfeld angezeigt.
Function getDialog() As Object
DialogLibraries.LoadLibrary("Standard")
getDialog = CreateUnoDialog(DialogLibraries.Standard.FzgKostenDialog)
End Function
Sub DialogAusfuehren
oDlg = getDialog()
oDlg.Execute()
End Sub
Sub getAuswahl
Dim oDlg, oCtrl As Object
oDlg = getDialog()
oDlgControl = oDlg.getControls()
For i = 0 To 3
oCtrl = oDlg.getControl("ob" & i) ' "ob" heisst OptionButton, also "ob0" bis "ob3"
If oCtrl.State = True Then
MsgBox("ausgewählt: Nr. " & i)
End If
Next
End Sub
Ich hänge besser gleich mal die ganze Datei dran...
Ich komme echt nicht weiter deswegen.
Vielleicht kann jemand ein kleines Beispiel mit einem Optionsfeld kreieren? (ich kann dann versuchen, selber zu analysieren was ich falsch gemacht habe)
REM ***** BASIC *****
Public BootDlg as Object
Public ui_array(7)
Public ui_inArray(7)
Public anz_ui as integer
Public oConn as object
Public oStatement as Object
Public sqlString as string
Public oResultSet as object
Public sort_option_button_num as Object ' Option <-----------
Public sort_option_button_nam as Object
Public sort_option_button_hafen as Object
Public s_typ as string
Public s_hafen as string
Public s_ename as string
' Liste der Boote
Sub liste_boot
s_typ = ""
s_hafen = ""
s_ename = ""
' Dialog dlgEigner1
DialogLibraries.LoadLibrary("Listen")
BootDlg = createUNODialog(DialogLibraries.Listen.dlgBoot)
Dim boot_ret as integer
boot_ret = BootDlg.execute() ' Warten auf Eingabe
if boot_ret = 0 then ' Abbruch
BootDlg.EndExecute() ' Dialog "dlgEigner" schliessen
BootDlg.Dispose()
Exit Sub
end if
s_typ = BootDlg.getControl("Boot_TX_Typ").text ' Option <----------
s_hafen = BootDlg.getControl("Boot_TX_Hafen").text
s_ename = BootDlg.getControl("Boot_TX_NameKrz").text
sort_option_button_num = BootDlg.GetControl("Boot_OB_Nummer") ' Option <----------
sort_option_button_nam = BootDlg.GetControl("Boot_OB_Name")
sort_option_button_hafen = BootDlg.GetControl("Boot_OB_Hafen")
user_info_schreiben
liste_boot_aufrufen
End Sub
Sub user_info_schreiben
dim sql as string
dim s_string as string
dim v1feld as string
dim v2feld as string
dim iCount as integer
dim table as string
dim sqlString1 as string
dim sqlString2 as string
anz_ui = 6
ui_array(0) = "ui_user"
ui_array(1) = "ui_prog"
ui_array(2) = "ui_info1"
ui_array(3) = "ui_info2"
ui_array(4) = "ui_info3"
ui_array(5) = "ui_info4"
ui_array(6) = "ui_info5"
ui_inArray(0) = global_Ben_Name ' Name user
ui_inArray(1) = "boot" ' Programmbezeichnung
s_typ = s_typ & "%"
s_hafen = s_hafen & "%"
s_ename = s_ename & "%"
sql = "SELECT * from boot WHERE ( bo_typ LIKE '" & s_typ & "' AND bo_hafen LIKE '" & s_hafen & _
"' AND bo_eigner_krz LIKE '" & s_ename & "' AND bo_aktiv IS NULL) ORDER BY "
if sort_option_button_num.state = true then
s_string = "bo_nummer ASC"
end if
if sort_option_button_nam.state = true then ' Option <----------------
s_string = "bo_eigner_krz ASC"
end if
if sort_option_button_hafen.state = true then
s_string = "bo_hafen ASC"
end if
sql = sql & s_string
ui_inArray(3) = sql
v1feld =" ("
v2feld = " ("
For iCount = 0 To anz_ui
v1feld = v1feld + ui_array(iCount)
v2feld = v2feld + """" & ui_inArray(iCount) & """"
if iCount < anz_ui then
v1feld = v1feld + ", "
v2feld = v2feld + ", "
end if
Next iCount
v1feld = v1feld + ")"
v2feld = v2feld + ")"
oConn = dbConnection ' Infos in Datenbank einfügen
oStatement = oConn.createStatement()
sqlString1 = "INSERT INTO "
table = "user_info"
sqlString2 = " VALUES "
sqlString = sqlString1 + table + v1feld + sqlString2 + v2feld
oStatement.executeUpdate(sqlString)
End Sub
Sub liste_boot_aufrufen
' Vorlage "Boot_Uebersicht.odt" laden
dim zw_vorlage as string
dim oDesktop as object
dim oDocument as object
Dim myProp(0) As New com.sun.star.beans.PropertyValue
oDesktop = createUnoService("com.sun.star.frame.Desktop")
zw_vorlage = global_vz_pfad & "Liste_Boot.ods"
zw_vorlage = ConvertToUrl(zw_vorlage)
myProp(0).name="MacroExecutionMode"
myProp(0).value = 4
'myProp(1).name="ReadOnly"
'myProp(1).value = true
oDocument = oDesktop.loadComponentFromURL( zw_vorlage, "_blank", 0,myProp() )
End Sub