Public Function With Form Scope?
May 17, 2012
I have a Function for checking the input in a textbox and only allowing Numeric & Backspace; everything works fine so far. My form is for financials and it has about 20 textboxes; they all receive Numeric only data; there is NO alpha data on the entire form required. Note in the snippet below that I don't even need a decimal point as well.
Is there a way to handle ALL textboxes on this form without having to place the Function call in each textbox KeyPress event. took a long (5 year) hiatus from developing VB6
Public Function TrapKey(ByVal KCode As String) As Boolean
If (KCode >= 48 And KCode <= 57) Or KCode = 8 Then
TrapKey = False
[Code].....
View 5 Replies
ADVERTISEMENT
Aug 23, 2009
I have a public variable which seems to be going out of scope. I am confused as it has been dimensioned as a public variable: Public xlCell as As Microsoft.Office.Interop.Excel.Range
I originally had all my code in the same module in the same project and it was wrapped within a For/Next Loop (Example 1). I decided to clean up my code and make it more modular (Example 2). All the code is still in the same module in the same project.
Upon doing so, my public variable is not recognized in any of the private subs that I have created. I keep getting the following error: Message="Object reference not set to an instance of an object." When I test the variable using ?IsNothing(xlCell) in the Main Sub I get False in the main sub. this tells me te variable is recognized. However as soon as the Call SelectCaseSub() is triggered, I get a True value for ?IsNothing(xlCell). Why is this? Shouldn't this variable be in scope regardless?
[Code]...
View 6 Replies
Nov 18, 2011
Is there a way to do something like this?
Public Enum CarMakes
Honda
BMW
Mazda
Friend Yugo
End Enum
I need to expose the the Enum to Public except for one of the items I just want to be available from inside the assembly.
View 1 Replies
Nov 27, 2010
I'm using VB.Net. I have a WPF User Control called "NavigationPanel" which I created with the Designer. By default, its scope is Public. When I change its scope to Friend in the file NavigationPanel.xaml.vb, I recieve the following error:
[Code]....
View 1 Replies
Jun 12, 2011
I want to know what implies to declare a function or a sub using public or directly Sub / Function i.e.:
Public Function Whatever()
' Process
End Function
versus.
Function Whatever()
' Process
End Function
View 4 Replies
Mar 1, 2011
[Code]...
i have a function that i have in my data access class now i want to access it then declare and assign parameters and then insert data into database.
View 4 Replies
May 18, 2010
Just had a small doubt.Say i use something like this
vb Dim ownr as New Form1Dim Dlg as New Form2ownr.Showdlg.showdialog(ownr)
how should i call an public function of form1 in the form2 if form1 is owner of form2, and also if form1 is not the owner of form2 should i use FormName.FunctionName in both the cases.
View 3 Replies
Apr 5, 2010
I am using VB2008 In the Form1, i have coded
Public Function getText(ByRef ctlName As String) As String
getText = Mfg.get_TextMatrix(Mfg.Row,Mfg.Col
[Code]...
View 5 Replies
Jun 26, 2011
I am having a toolstrip in the mdi form which contains save, update delete and clear buttons. The child form is having save, update, delete and clear as public sub routines , and client form will not have any standard buttons, I will click the respective button in the parent tool window which should call the child forms function.
View 1 Replies
May 31, 2011
explain me the difference between them? I'm new to visual basic, and I need to know the very basic things in Visual Basic allowing me to become a professional User
View 8 Replies
Dec 4, 2011
I want to create a new instance of a class when I click on a button, but I need to interact with members of that class using other controls on the form, so I need the class to have a global scope. I know I could call the new class in formload, but the class creates certain variables that need to be current. If it is done on formload, the variables wouldn't be current, because if the class is created at formload, it would have different info at that time. Surely, there must be a way to create an instance of the myClass from within a sub that is accessible from other subs of the same class.
[Code]...
View 2 Replies
Nov 10, 2009
I am trying to acccess a Collection in another form
vb
MsgBox(frmNetworkTest.servers.Count)
What I do this from the same form, I get 16, but when I run this code from a different form, I get 0.The variable is declared public.
vb
Public servers As New System.Collections.ArrayList()
View 5 Replies
May 18, 2012
I'm trying to fix all my project warning according to Microsoft code analysis (CA:XXXXX) One of the warning is "CA2000: Dispose objects before losing scope" My Code is:
[Code]...
View 2 Replies
Nov 22, 2011
I have a public function to call default email client.Public Function OpenEmail(ByVal EmailAddress As String, Optional ByVal Subject As String = "", Optional ByVal Body As String = "") As Boolean
[Code]...
View 1 Replies
Apr 18, 2011
I have a public function to call default email client.
Public Function OpenEmail(ByVal EmailAddress As String, Optional ByVal Subject As String = "", Optional ByVal Body As String = "") As Boolean
Dim bAns As Boolean = True
[code].....
View 6 Replies
May 15, 2009
Here's what i would like to know, i will post my layout below.
CODE:
Right what i want to do is when i click my button it goes to the timer3.tick.. i then want it to use the public function on the listbox's.
View 39 Replies
Oct 15, 2009
If I have a Windows Application WinApp that has a public function pubFun, how can I call it from a different windows application --> WinApp.pubFun() ?
View 2 Replies
Feb 19, 2011
I have to create a program that finds the total cost for pizza, fries, and soft drinks, and places that in a list box. So far, though, I'm stuck. I have this code so far:
Public
Class frmBill
Private
Sub btnTotal_Click(ByVal
sender As System.Object,
[Code] .....
The errors that I am getting are:
"Argument not specified for parameter 'D' of Public Function totalBill(P As Double, F As Double, D As Double)
"Argument not specified for parameter 'F' of Public Function totalBill(P As Double, F As Double, D As Double)
"Argument not specified for parameter 'P' of Public Function totalBill(P As Double, F As Double, D As Double)"
View 3 Replies
Apr 27, 2011
For example we generally apply threading to make application faster and unnecessary timetaking not related to UI things can go in secondary threads.Now If I have a user control
This control contains a public function LoadControl() Function is called from the form which is using the user control In side function
[Code]...
View 1 Replies
Jan 11, 2011
I am trying to create a Public Sub / Function that will allow me to pass certain variables into it and this will affect the output. e.g.
DIV ID = InfoDiv
CSS Class = "Warning"
LBInfoMsg.Text = "An Error has occured"
DIV Visibility = True or False
I would like to type something similar in the code behind page:
InfoMsg(InfoDiv, "warning", "An Error has Occurred", True)
Public Sub InfMsg(ByRef MyDIV As System.Web.UI.HtmlControls.HtmlGenericControl, ByRef CSS As System.Web.UI.WebControls.Style, ByVal strMessage As String)
strMessage = strMessage.Replace("'", "''")
MyDIV.Attributes.Add("Style", "warning")
MyDIV.Visible = "True"
End Sub
View 1 Replies
Oct 29, 2009
Class A gets, as part of it's constructor, a pointer to class B and saves that pointer in a private variable. Class B exposes a public function, F. I'd like for class A and all classes that inherit from class A to NOT be able to call B.F.The idea is that class A will implement its own version of F, one that calls B.F, but the rest of the code should not be calling B.F. If it matters, the two have different function signatures.Maybe another way, like a class C that inherits from class B and hides the public functions? (Cant that even be done?)
View 2 Replies
Aug 30, 2009
I have a public function declared in my code-beside on default.aspx.vb. I needed to add a second page to my project and copied and pasted that function into the second page, but when I test the page I get an error saying there's a conflict with the same public function on the default page.
If I remove the function from the second page, i don't get the error, but will it still be accessible if called on that page, even though it's on the default page? Or do I need to place it somewhere else so that it's accessible to both pages?
View 2 Replies
Aug 6, 2009
I made the changes from this:
[code]...
to this:(the 'End Function' says "Function 'GetFolderPath' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used."
[code]...
View 4 Replies
Nov 2, 2009
I have a situation where I have several VB.NET Modules in the same Logical-Module of a large application. I would like the update function of each module to be public, but I would like users to be forced to qualify the function call with the module name.
ModuleName.Update()
instead of
Update()
Is this possible?
View 2 Replies
Jul 22, 2011
I am somewhat stuck on this little problem, I am using Visual Basic 2010
Error3Too many arguments to 'Public Function Calculations(txtSoilTemp As Double, txtSupplyTemp As Double, txtCarrierPipeWallThickness As Double, txtInsulationThickness As Double, txtJacketThickness As Double, txtExternaldiameterofcarrierpipe As Double,
[code].....
View 2 Replies
Jul 20, 2009
Im new in this forum. I just recently upgraded my Visual Studio 2003 to Visual Studio 2008.I have a web project which is working very well in Visual Studio 2003. But when Im trying to run the same project in Visual Studio 2008, Im getting a runtime error message.The error message is about a public function which is defined in a public module. When Im trying to call that function from different web pages of my project, the web pages are not recognising the public functions and asking me to
View 3 Replies
Nov 25, 2010
I am trying to do a simple program where I have a public structure and public function in a code file, the problem is I want to return two integers. Here is the code from my code file.
[Code]...
View 7 Replies
Sep 24, 2010
I have a windows app that references a web service I created. In the web service, I created a function that needed to return more than one value. Because of this, I created a public structure in the web service:
Public Structure MyRecordSet
Public lstOfDataInRecord As List(Of String)
Public iNumberOfRecords As Integer
End Structure
Here's the function - the return value is MyNewRecordSet:
Dim MyNewRecordSet As MyRecordSet <WebMethod()> _
Public Function GetDataReturnList(ByVal sql As String, ByVal sTableName As String) As MyRecordSet
MyNewRecordSet.lstOfDataInRecord = New List(Of String)
[Code] .....
Anyway, I see it's a conversion issue, but not sure how to resolve it. This is my first attempt to use a public structure in a web service and receive a return on it from my app.
View 1 Replies
Oct 2, 2009
why I am getting a NULL reference error. Form: Public Sub CreateSession() ' This will be the execution function after the date, provider, session type, session number ' and consumers have been entered. Each Consumer will have it's own tabpage and seperate record.
[Code]...
View 31 Replies
Apr 18, 2012
I'm struggling with a thing or two...and i've read some stuff about the backgroundworker but im stuck Basically what i have is a : PUBLIC FUNCTION TEST (path as string) : which at the end of work , adds an item to the form1.listbox. That works quite nice but freezes the app. I've tried using the backgroundworker, the function in the background worker seems to work nicely, the bad thing is that i dont get any results in the form1.listbox.
View 14 Replies