How to get content from field - libreoffice-base

I'm totally new to Base. I have different forms but in one named F_STRUCT of them I'm trying to make a macro which will allow the user to autofill another field when he select a zipcode.
so the database looks like this.
ID_ZIP ZIP CITY
1 97425 Les Avirons
2 82289 Toto
In my forms, I have a select which allows to select the ZIP code. It's label and name is ZipCode.
So I don't really know where to find the API reference for all the methods and chill methods, I followed examples from internet.
I tried this
Sub getZip
Dim Doc As Object
Dim DrawPage As Object
Dim Form As Object
Doc = StarDesktop.CurrentComponent
DrawPage = Doc.DrawPage
Form = DrawPage.Forms.GetByIndex(0)
Toto = Form.GetByName("ZipCode")
Print "hey"
End Sub
But it returns an error on the Toto = Form.GetByName("ZipCode") line.

The code works, so the problem must be how you created the form or control. Follow these instructions to set up a correct example:
Create Form in Design View
Use the List Box tool (is that what you mean by "select"?) and create a control.
Cancel out of the wizard if it pops up.
Right-click on the control and select Control Properties (not Name, which would modify the shape name instead of the control's name).
Set the Name to "ZipCode" (without quotes).
Save and close the form.
Open the form. In the window of that form (the CurrentComponent) go to Tools -> Macros -> Run Macro.
A list of documentation links for Base is at https://ask.libreoffice.org/en/question/80972/to-learn-libreoffice-base-are-there-introductions-or-tutorials/?answer=80973#post-id-80973.

Related

XCode: Additional localization of only one button

After a long long time, I added another button to my apps dialog. I had localized strings implemented. So I found a similar one like
/* Class = "NSButtonCell"; title = "Keep number"; ObjectID = "2yE-rM-5Sn"; */
"2yE-rM-5Sn.title" = "Nicht umnumerieren";
in file "Main.strings (German)". Unfortunately I forget, how I got there. I did the entire translation in one step in one night. Now I only need to get one new translation for the newly added button.
Any hint how to do this?
Select your project name (1.), in my case Timebooking. Maybe the application is selected instead in Targets and you have more options but not localization. Then select Use Base Localization (2.). It should create the English Main.strings file when you add English. There you can add the proper translation. HTH.

Display a different image on combo box change in Access without file paths

I am creating a form that contains a combo box, lets say it's called 'Postcode_cb'. I want to have a unique image displayed for each of the items in that combo box. The images have to be in the same position and replace each other when the combo box is changed so that there is only ever 1 image. This has to be done without the use of file paths.
For example:
Try this way: create table [tblImg]([id], [picture]) where [id] is long and [picture] is OLE.
Insert two records with id=1 and id=2, embed corresponding images into [picture] field.
Then create stanalone form [frmImages] with rowsource [tblImg] and put 'bound object frame' with control source [picture].
Put [frmImages] as sub form at your main form.
Set LinkMasterFields to [Postcode_cb] and LinkChildFields to [id].
I have something like this on a database that gives out star rating of hotels. As you browse through the hotels it displays actual stars depending on the rating. The way that i did this was placed all the images in 1 spot (Placing them on top of one another) Give each image a name. and set them all to visible = no.
Example Img1, Img2 etc. until all images have a name.
Then open Visual basic and create a sub called Private Sub Form_Current() if you don't already have one. Then under this sub use the following Code
Forms![FormName]![ComboBoxName].SetFocus
Select Case Forms![FormName]![ComboBoxName].Text
Case Is = ""
Forms![FormName]!img1.Visible = False
Forms![FormName]!img2.Visible = False
Case Is = "1"
Forms![FormName]!img1.Visible = True
Case Is = "2"
Forms![FormName]!img2.Visible = True
End Select
This is only good if you only have something like 5 to 10 images anything more would be a lot harder to deal with in this way.
There maybe other ways people can suggest i found this the most easiest for my needs.

Comparing Data In Text Boxes in Visual Studio 2013

So I mostly use Microsoft Excel for a lot of my work and the most "Programming" I do is writing basic logical functions in excel.
I am setting up a windows form in Visual Studio 2013 and I want to the end user to be able to be able to confirm that the data they input into TEXTBOX1 matches what is in TEXTBOX2.
So normally in excel I can just write =IF(C2=D2,"Yes","No")
So basically I want to be able to input data in the carton field and then in the label field and if it matches I want it to say yes in the text box at the bottom.
I tried writing
If CartonBarcode = LabelBarcode Then
PartCheck = "Yes"
Else : PartCheck = "No"
End If
but that hasn't worked - I am very new to VB so please be gentle.
Eventually I also want to be able to append the scanned data (If the two text boxes match) into an excel spreadsheet.
Thanks in advance for all your help =)
Thanks for your help Mark - that makes a lot of sense.
I added this IF Statement to the PartCheck text box but it doesn't seem to display Yes or No regardless of what I put in.
It now throws two errors (look to be the same error on each line.)
Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'
Any further help you can provide would be fantastic
Screenshot of errors
I then changed PartCheck = "Yes" to PartCheck.Text = "Yes" and it runs but then nothing displays in the PartCheck Text Box
In WinForms, TextBox and other GUI components (e.g. Label, Button) are objects, with properties and methods to interact with them. If you want to compare the text that has been entered into two TextBox objects, you will need to compare their Text properties. e.g.
Update
Updated code below based on your updated question. You are correct that you need PartCheck.Text = "Yes" to set it correctly. Your current issue is when you are performing the check. You are handling the TextChanged event for your PartCheck TextBox, but your logic should really be triggered when either the CartonBarcode or LabelBarcode text is changed. You can either have TextChanged handlers for both of those TextBox controls, and call a common subroutine to perform the check, or have a common TextChanged handler, as shown below:
Private Sub Barcode_TextChanged(sender As Object, e As EventArgs) _
Handles CartonBarcode.TextChanged, LabelBarcode.TextChanged
If CartonBarcode.Text = LabelBarcode.Text Then
PartCheck.Text = "Yes"
Else
PartCheck.Text = "No"
End If
End Sub

Find a button on a web page looking for part of its InnerText string in Visual Studio

I am writing automated tests for a website. On the website there is a button that will have the inner text "All Open" + four random digits. For example: "All Open2957". Is there a way to find the button using only the "All Open" part of the string?
This does not work since the string is missing the four last digits:
HtmlSpan uIAllOpenPane = new HtmlSpan();
uIAllOpenPane.SearchProperties[HtmlDiv.PropertyNames.InnerText] = "All Open";
The simple answer is to use the PropertyExpressionOperator.Contains rather than PropertyExpressionOperator.EqualTo comparator and search for just the required text.
For recorded tests, find the control in the UI Map editor and view its properties panel. Click the "Search properties" field and then click the ellipsis. The window that appears allows the comparator and the required text to be altered.
For hand coded tests use code of the form:
uIAllOpenPane.SearchProperties.Add(HtmlDiv.PropertyNames.InnerText,
"All Open",
PropertyExpressionOperator.Contains);
According to this Microsoft blog the array index style (ie with [ and ]) as used in the question internally calls the SearchProperties.Add(...) but that style has no variation to specify ...Contains, so call the ...Add(...) explicitly.
Check this out
Button allOpenButton = (Button)BrowserWindow.ExecuteScript("allOpenButton = function(){var found; $('input[type=\"button\"]').each(function(){ if($(this).val().indexOf('All Open') > -1){ found = $(this);};}); return found;}; return allOpenButton();");
When trying to locate the controller I only got the FailedToPerformActionOnHiddenC‌​ontrolException. Eventually I was able to locate the DIV container that contained the controller I was trying to locate instead of focusing on finding the controller directly. After finding the container I could locate the controller using
HtmlSpan uIAllOpenPane = new HtmlSpan(container);
uIAllOpenPane.SearchProperties.Add(HtmlDiv.PropertyNames.InnerText, "All Open",
PropertyExpressionOperator.Contains);
The code from #AdrianHHH helped with the problem when part of the string is randomized each time you encounter the controller.

How to type cast webbrowsercontrolobj.document to mshtml.HTMLDocument VB6? or How to submit form loaded in webbrowser control in vb6?

Hello I am writing code in VB6 only (no VB.NET)
I have webbrowsercontrol object named webbrowser1
I have added reference of microsoft html object library in project.
I am trying this line but is giving error.
Dim doc as MSHTML.HTMLDocument
doc = DirectCast(webbrowser1.document, MSHTML.HTMLDocument)
line 2 is giving error that no method or data found at MSHTML.HTMLDocument
Please help me solving this problem.
What I want is I have one webpage having 2 (html forms) in it. I am loading that page into
webbrowser control by,
webbrowser1.navigate "url"
I have mapped event to handle html button click in webbrowser1's document.
When user clicks on this button I want to submit second form of html page.
Is there any other way to do it?
I also tried following code
'this line is working properly
'this is the code to submit first form in html page
webbrowser1.document.Forms(0).submit
but when I do
'this line is giving error though there are 2 forms available in html page
webbrowser1.document.Forms(1).submit
So ultimate goal is to submit second form of html document.
Please show me right direction.
You need to change Dim doc as MSHTML.HTMLDocument to Dim doc as MSHTML.IHTMLDocument.
Notice the IHTMLDocument has an I at the start, then try to submit the form.
Also, there is no such thing as DirectCast in VB6 - that is only a VB.NET thing.
So just do this:
Dim doc as MSHTML.IHTMLDocument
Set doc = webbrowser1.document
Now you will get intellisense on doc. :)
Let me know how it goes.
Have you tried just direct assignment?
Dim doc as MSHTML.HTMLDocument
Set doc = webbrowser1.document
VB6 doesn't really do casting, but you can access any method (early bound) by assigning it to an variable of the required type, or (late bound) by blindly using a variable of Object type.

Resources