Dim A Variable That Will Be Used Make A Class And Then Ferer To It?
Jun 10, 2010
Having trouble accessing a dim variable inside a btOk or Load event. when I dim a variable that will be used a lot, do I need to make it a class and then referer to it?
View 7 Replies
ADVERTISEMENT
Aug 7, 2009
Sometimes to make a variable/method/class name descriptive I need to make it longer. But I don't want to, I'd like to have short names that are easy to read. So I thought of a special addin to IDE like Visual Studio to be able to write short names for class, method, field but be able to attach long names. If you need to - you can make it all long or you can make single name long. If you want to reduce it - use reduction, like two views of the same code. I`d like to know what others thinking about it? Do you think it is usefull? Would anybody use the kind of addin?
View 12 Replies
Sep 26, 2011
i had a class called Tag with a structure like:
public class Tag
private _members
public properties
public shared database_methods
end class
this class was tailored for mysql database. i'm currently adding access 2007 support so i split tag into tag and tagdata with structures like:
[Code]...
View 2 Replies
May 8, 2012
Create a class named Service. Inside the Service class, declare a class variable named Started. The datatype of this variable is Boolean.Public Class Service Dim started as Boolean End Class Create a class named Server. Inside the Server class, declare a dynamic array that can contain elements of the type Service.(Note: For convenience, both the array and the variable Started can be accessible from a client program that creates an instance of Server and Service respectively)
Create a constructor for the Service class. When the constructor is executed, it will set the value of the class variable Started to True. Create two new classes: WebServer and DatabaseEngine. Both of these classes inherit from the class Service. Inside the Service class, declare a Sub procedure (method) named Terminate. This method should display the following text Service stopping in a message box when executed.This method can be overridden in classes that inherit from Service class.
Inside both the WebServer and DatabaseEngine class, override the method Terminate inherited from their base class Service. Both methods should first call the base class Terminate method. The messages Web server stopping and Database engine stopping should also be displayed in a message box when the Terminate method for the WebServer and DatabaseEngine are called respectively. These messages should only be displayed if the Started variable inherited from their base class is not equal to False.
Inside the Server class, declare a method named Shutdown. This method does not return any value. When executed, it will call the Terminate method for each of the Service instances (if any) in the arrServices
array. You should call the Terminate method within a For Each loop that loops through the elements of the arrServices array.
In the Sub Main method, create an instance of the class Server. Set the size of the arrServices array in
your Server instance to contain 2 elements. Create first a WebServer instance and then a DatabaseEngine
instance into this array. Call the Shutdown method from your Server instance.
View 7 Replies
Jun 7, 2012
I want to created a nested class that can only be visible to and instantiated from the parent class.But I also want to be able to use an instance of the nested class through a public variable of the parent class.I tried making the nested class private, or making the nested class' constructor private, but it won't compile.Is it possible to do this in .NET?
[Code]...
View 3 Replies
Sep 29, 2011
I have procedure (Import) that calls a for a new instance of frmImportData. I also have a class name clsBatch that has a data table property called prpParametersTable.For some reason, I get an error (indicated below with ERROR>>>) when trying to assign prpParameterTable to cv_dtImport2. The error states "Object reference not set to an instance of an object.". Why does this error not happen when I assign dtBP to cv_dtImport1? Both cv_dtImport1 and cv_dtImport2 are equal to Nothing and in my Import procedure dtBP = prpParametersTable.
Public Sub Import(ByVal clsB As clsBatch)
Try
Me.cv_clsB = clsB
[code]....
View 5 Replies
Nov 14, 2009
I have three class files, accounts.vb and transactions.vb in addition to my form.vb. I am unable to retrieve a member variable from on class from inside the other. When the combobox index changes, the program loads the correct account (checking or saving) from two different sequential files. I don't think I have the calcBalance procedure in the correct class file. And that is what I am having trouble with. Accessing it to display it. [Code]
View 1 Replies
Dec 18, 2009
What i'm trying to do:
I've got a library which includes a class:
Class Human
End Class
and another class which refers to the human class
Class ASD
Private somevar as new Human
End Class
Ok now i've got a problem, i wish to rename my class Human, to Man. i've got to change Human to Man 2 times, which is OK but the problem is that in the real case, its not just 2 times, its like 500 times or more.
Well its something like a PHP on Javascript.
the following shows the solution of what i'm trying to do, but its in another language PHP/Javascript:
note: in php $ sign declares a variable, echo writes the variable out
CODE:
Is there anyway to do that with VB?
View 6 Replies
Jan 31, 2011
I have the following code:
Option Explicit On
Imports System.DirectoryServices
Imports System.IO
[code].....
View 4 Replies
Sep 5, 2010
Using Visual Basic 2008 Express. I need to pass a variable to another form. Or else make the variable visible to both forms.
View 4 Replies
Feb 9, 2011
The code below works for the class that I hard coded "XCCustomers" in my RetrieveIDandName method where I use CType. However, I would like to be able to pass in various classes and property names to get the integer and string LIST returned. For example, in my code below, I would like to also pass in "XCEmployees" to my RetrieveIDandName method. I feel so close... I was hoping someone knew how to use CType where I can pass in the class name as a string variable.
Note, all the other examples I have seen and tried fail because we are using Option Strict On which disallows late binding. That is why I need to use CType.I also studied the "Activator.CreateInstance" code examples to try to get the class reference instance by string name but I was unable to get CType to work with that.When I use obj.GetType.Name or obj.GetType.FullName in place of the "XCCustomers" in CType(obj, XCCustomers)(i)I get the error "Type 'obj.GetType.Name' is not defined" or "Type 'obj.GetType.FullName' is not defined"
'+++++++++++++++++++++++++++++++
Imports DataLaasXC.Business
Imports DataLaasXC.Utilities
[code]....
View 2 Replies
May 15, 2009
I can't make difference between public class and private class and friend and protected friend class.
View 1 Replies
Feb 17, 2011
I have a VBA form in Microstation I am using to try and help automate a task. The only problem I am having is I am reading a textbox (Filebox.Text) and setting it as the variable (FN). It works, because I used Msg.Box (FN) to test it. However, in two of the lines of code, I am trying to use (FN) to pass the typed in filename to the command to run in Microstation. Unfortunently, it gets passed on as (FN).dgn instead of the actual filenale typed into the textbox. Is there a way I can make the variable actually seen as a variable? Code on Pastebin: url....Also, not sure if this is the right section, 100% new to VBA, coming from a world Bashed together.
View 3 Replies
Feb 28, 2012
I am New to <acronym title="Visual Basic">Vb</acronym>.Net. this is my first test. i try to create small address book. but i don't know what wrong. it compile perfect but when it run it give error and not work. is there any other way to add same class like in class inside array?
[Code]...
View 6 Replies
Jan 13, 2010
Public Class form1
Private Sub btnAnswer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAnswer.Click[code]........
how can i make vb realize that the side that is opposite of the given angle, has to be less than the other sides. Also im not sure what Acamar meant by If txtAngleA.Text <> "" AndAlso txtAngleB.Text <> "" AndAlso txtSideA.Text <> "" Then 'two angles and a side Because im not sure what <> does.
View 1 Replies
Mar 9, 2010
How does a class get the name of the variable that instantiated it?[code]...
View 9 Replies
Aug 15, 2011
I have 2 subs in my class. I need to use the values in the variables in the first sub in my second sub. like this.
Public sub test1()
Dim one as double = 12
Dim two as double = 10
[CODE]...........
But I do not remember how to do it.
View 1 Replies
Mar 12, 2012
I have form1.vb and class1.vb
Code removed
What I am trying to do is very simple now. Pointx and Pointy in Class1 is underlined. How do I get that variable value (which the form1 finds) into class1.
View 14 Replies
Apr 13, 2009
I'm getting an error in .net when trying to declare a Public class on my code behind page.
Partial Class _Default Inherits System.Web.UI.Page
Public someVariable as integer
Public someClass as className
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load [...]
The error I'm getting is BC30508: 'someClass' cannot expose type 'className' in namespace '<Default>' through class '_Default'.The goal here is accessing the class properties in script blocks on the aspx page like this <%=someClass.classProperty%>
I'm not sure if I'm trying the right methods (I've tried several ways of declaring the public class) or if it can even be done..
View 3 Replies
Mar 4, 2012
I want to do this: [URL] but in VB. I believe that is for C# I have 2 classes.
[Code]....
I know I've been asking too many questions lately and I do apologise for that. I am trying to learn the basics
View 12 Replies
Dec 1, 2011
how to access the variable from another [Code] I need to call the variable invoiceno in the class xmlserializer using ord1 and assign the value which the user enters during the runtime.
View 6 Replies
Jul 17, 2009
How can I call a class from a variable ?
Something like :
Dim strClassName As string = "clsAction"
Dim newclass = strClassName
I know that this code doesn't work, but how can I do it, if possible.
View 4 Replies
Mar 8, 2012
Looking for the best way to update a variable in a different class. Below is a rough outline of the situation.
I am wondering if in fnSendEmailTo if I can access the Property in CB?[code]...
View 4 Replies
Jun 12, 2011
how to declare scope for variables outside their class?
Here's what i have in a class known Create_User:
Public Class Create_User
Public conn As New SqlConnection(My.Settings.HotelConnectionString)
Public usercmd As SqlCommand
[Code]....
How can i increase the scope of these variables to be used in another class? I dont want to keep declaring them again and again.
View 4 Replies
Dec 25, 2011
Class1:
Dim v as integer
public sub storeVar(byval s as integer)
v = s
end sub
[code].....
I need to save a reference of variable s in Class2 in variable v in Class1.(i.e. when the value of s changes v also changes (and vice versa)Is this possible since vb.net doesn't have pointers?Will it work if I change "byval" to "byref"?
View 1 Replies
Nov 12, 2010
i have
VariableA as Class1
Variable1 as string
Variable1 = "VariableA"
I want to be able to use Variable1 to get access to VariableA(?).
So i want to able to do something like
VariableA.Property1 = "test"
But like this:
Variable1.Property1 = "test"
View 5 Replies
Mar 31, 2009
I think I remember reading somewhere that it was possible to assign items to a variable if the item inherited from a base class, but I can't remember how.
I want to have a class that gets properties set and one of the properties is an error code property. I want to assign any exceptions that occur to the property, but it could be any type of exception. I remember that all exceptions inherit from the Exception class.
How can I assign an exception to a property based on the class it inherits from?
View 4 Replies
Sep 30, 2009
i'm working on a code that i want to start creating new classes with but i want to know if there's a more direct way to send the variables used in the form to a new class for storage.
for example i've got this on a form...
Dim ClassID As String
Dim ClassName As String
Dim Grade As String
[Code]....
you know? so what would be my most direct route to get this? how should i start?
View 15 Replies
Jul 26, 2010
I have a text file to read, at the first line will have a size of array, that means I cannot guess size of array, and I have to create a array in side a sub (Local Variable). Then, I want to use value of array in another sub, but I cannot use value of variable of another sub. What I have to do to make an array con be used in every sub/function in a class? Also, I've post an example file, code and error list.
[Code]...
View 1 Replies
Apr 5, 2011
I have a class that I would like to link at construction to a given control (say a textbox)
I know I can put a variable into a subroutine referentially but is there a way to store it in the same capacity?
View 1 Replies