I can't use the right function in MS Access - vba

I can't use the right function in MS Access text box with this code :
=Right("computer",2)
or
=Right("computer";2)
BUT The other functions work

Try
=Right(format$(shamsi()),2)

Related

How to use a string as a visual basic object?

I have a form with lots of Picture boxes, is there a way to call them using a string? Something like
PctBox+str(number) would give me the name of the box on the form, so I can loop through and change them all without having a huge block of code?
Are we talking about Microsoft Access?
If so, you can use this sample, assuming your picture box controls are named PctBox1 - PctBox3 for example and you place the code in a procedure in the form:
For index = 1 To 3
MsgBox(Me.Controls("PctBox" & index).Name)
Next
This sample just shows up the name of the each of these controls.

Autocompleting Parameters of a function in intelliJ

I have a function with parameters.
I like to use this function and would like to see the parameters that I have to provide to this function.
How can I force IntelliJ, that it shows me the parameters needed for that function when my cursor is in the () of that function ? Ctrl-Space do not help me out.
try CTRL+P
its shows you the type and the name
Press CTRL+SHIFT+A and search for Parameter Info and it will show u your hotkey

Visual Basic cannot using form when coding

I have a form called "cancel reservation", so when i try to calling this form in my coding , it cannot be call.
Please check my attachment here
I can using call for all other form but not this one, can anyone please give some advise?
Thank you
Your form's name is most likely just Cancel_Reservation instead of formCancel_Reservation (that is, if you've not renamed it of course).
For example:
Cancel_Reservation.Close()
should do the trick.
Use show() function to call forms.If your form name is Cancel_reservartion then call like this,
Cancel_reservartion .show()
Just try it.

VBA how to enable a Click Event in a subform?

I have a Subform, which shows the results of a search, using Data of many searchboxes. I'd like to use a subform instead of a ListBox, because so the user can use the OrderBy and filters. Now I want that the user can doubleclick a field, and receive the first value of this row.
Me.SearchResultForm.Form.RecordSource = query 'query contains the precalculated sql query
Me.SearchResultForm.Requery
This works really well.
Me.SearchResultForm.Form.OnDblClick = onResultDblClick '--> a function
This does something strange: It fires once at requery, but NOT at doubleclick...
How can I get this working? Or is there a better solution?
Thanks for your help!
Try the following:
Me.SearchResultForm.Form.OnDblClick = "=onResultDblClick()" '--> a function
As noted on msdn here, when setting an Event Property, you assign it a string that is either a Macro, an Event Procedure or a User Defined Function.

Lambda expression error in vb.net

I'm a newbie to this linq stuff. I never used any linq before. So when I had a scenario to move selected items from left list to the right list, I've got a nice solution from search which is in C#, but I converted it into VB. here is the code I've got
Dim leftItems = lb_left.Items.Cast(Of ListItem)().ToList()
Dim rightItems = lb_right.Items.Cast(Of ListItem)().ToList()
'Get all selected items from left box
Dim LeftSelectedItems = leftItems.Where(Function(a) a.Selected).ToList()
'Add all selected items to right box
'Clear lb_right Items and add sorted list
lb_right.Items.Clear()
LeftSelectedItems.Union(rightItems).OrderBy(Function(a) a.Text).ToList().ForEach(Function(b) lb_right.Items.Add(b))
'Remove all selected items from left box
LeftSelectedItems.ForEach(Function(a) lb_left.Items.Remove(a))
The above is the code I got from internet to move left to right list box. But on that function in the ForEach it is giving me a kinda error "Expression does not produce a value"
I really got stucked with this error. Requesting your fast reply..
LeftSelectedItems.ForEach(Sub(a) lb_left.Items.Remove(a))
From the documentation for VB lambda expressions:
The body of a single-line function must be an expression that returns a value, not a statement. There is no Return statement for single-line functions. The value returned by the single-line function is the value of the expression in the body of the function.
As the compiler says, Add doesn't return a value.
I believe you could use Sub instead of Function, and use the multiline version - but I don't think that's the best way of working here.
It looks like you should be creating a query and then using a sort of "add all these items" call. Unfortunately you haven't told us the type of lb_right, or even whether you're using WPF, WinForms, ASP.NET etc.