Error coming up almost everytime I run my aplication from VS - vb.net

Please see the pic. and advise why this error is coming up and how to fix it.
Thanks

Change your datagrid column's name from "Name" to "colName". Me.Name is a property, so naming it "Name" is causing problems. This is one reason I like to use a type prefix (btn, txt, lbl, etc) to signify control type.

Related

VB.Net - Specified Cast is not valid But Debugger showing value

The code i am trying to run is a simple one. get text from a Textbox and display that via MsgBox. now i probably have done this a million times but i get a strange error. The Code is :
Dim s As String = FromDateTEX.Text.ToString
MsgBox(s)
I get this error from second line :
System.InvalidCastException: 'Specified cast is not valid.'
Here is the strange part : Debugger shows value for s which is correct. here is the screenshot :
What am i doing wrong here ?
Edit :
Even this code gets the same error :
MsgBox(“hello”)
One line above, you access the property EditValue of control DomainLUE. If LUE stands for LookUpEdit, do you happen to be using a 3rd party component library from a company like DevExpress?
If that is the case, is FromDateTEX a textbox (TextEdit) control from this library too? In that case, FromDateTEX might also expose an EditValue property. Then you might try to convert that value to a string:
Dim s As String = FromDateTEX.EditValue?.ToString()
I am not sure why the Text property is problematic here. I would expect it to work just fine. Very strange.
Oh, by the way, sometimes Visual Studio goes a little bit berserk. Closing Visual Studio, optionally deleting the .suo file, restarting Visual Studio and reopening the solution might help too...
Turns out the error was from the above line. LookupEdit 's EditValue was in fact a Short and it needed a Convert to Integer.

MS Access VBA - extract listbox value on a form (using form name.)

This seemed to be working but just stopped and I'm not sure what I changed to cause this.
I have a listbox on a form. (a single select listbox).
To extract the value, I can do me.listboxName.Column(0) and that works perfectly.
However, that's not the code I want to use. (as I will reference it from another form )
Form_myformName.listboxName.Column(0)
is what I had, and it worked and now it's stopped. It still works for similar code on other forms, so I'm not sure what's happened.
If I type in me.name, it tells me correctly that my form name is "myFormName".
If I type in Form_myFormName., it prompts me with the name of my list box so I know I have the names correct. However, if I try to extract the value using:
Form_myformName.listboxName.Column(0)
it gives me a value of Null, despite the listbox having a selected value. (which I can sucessfully extract by using me.listboxname etc)
hopefully that makes sense. anyone know what I'm doing wrong?
Try it this way:
Forms("myformname").listboxName.Column(0)
I hope that helps.

Backand: Object exists but not able to access it

I'm using Backand for my backend service where I have an object that exists in my model diagram but I can't access it. Whenever I try, I get an error that the table doesn't exist. I can't delete it. I've tried renaming it but it only took a single additional character to the name. I've tried to edit it and remove it in the model json area but to know avail. Any help would be greatly appreciated. Thanks.
Are you sure you click on save button in bottom of model page?
I was able to get this corrected. My problem came about that at some moment, I went to the Object's Settings tab. There are two "Names" at the top of that. "Name" and "Database Name". At some point I had changed the "Name" (which is editable) which cause the "Name" and "Database Name" to be different which caused queries to have problems.
So to correct this issue - I renamed the "Name" to be exactly what the "Database Name" is (having to do so slowly as it has an event trigger each time you make a change so it has to wait for the confirmation of each save before typing the next letter). Once I got the "Name" and "Database Name" to match exactly, then I was able to refresh the Object Model and delete out the object. Then created the Object with the name I really wanted.

VB Stored Reference Lists

I've successfully developed a good portion of a project i'm working on. To add greater functionality and ease coding I'd like to have a "reference list" of properties to bridge the gap between the UI and code. A lot of the code will end up looking like:
object.property(SuperLongStringWhichActsAs.Integer.AndIsUnusableInUI)
or
object.property(integer)
So the integer relating to the "width" property might be 1, with a possible substitute value of "bunchoftext.efields.width", and I'd like to show it in the UI as "Width". If the user selects "Width" in the UI, I'd like the returned value to be "1" for use in code, as "object.property(Width)" will not work, but "object.property(1)" will.
Is there any way to store a list of strings and their related values to be referenced by the program?
Thanks in advance for any help!

Not allowing to rename a datagridview Column

Hi i am Naming a Datagridview Column as "Class" it is giving me a message
"'Class' is not a valid identifier"
Can anybody help me?
You can do it programmatically, just not in the form designer:
Dim dg As New DataGridView
dg.Columns.Add("Class", "ClassHeader")
I don't think you can call your column "Class" in VB.Net since it's a keyword. Name it almost anything else.