Programming Paradigm Called OOP - To Be An Object Or Not To Be An Object ?
Feb 25, 2012
I am in the process of learning this new programming paradigm called OOP (I am a very seasoned structured programmer). In that context I am receiving what I call contradictions in vb.net regarding the instantiation of an object. Given the two lines of code below:
Dim SQLcmd As New SqlCommand
Dim SQLdr As SqlDataReader
The first line is quite simple - SQLcmd is an object - period. It is the second line that is creating the ambiguity. One reference I have read says in order for a class to instantiate an object the key word "new" must be used. But I have also seen examples where SQLdr is also called an object? To add to the ambiguity I have seen class examples where the class was constructed without a new subroutine (a constructor) and called with the key word "new" which I have been informed by vb.net on more than one occasion in doing such that "there are no constructors" in the class. So would someone please tell me - Is SQLdr an object and if so is it by inheritance (the other escape path) or what; and lastly am I correct in my understanding that in order to use the key word "new" there must be a "new" subroutine/function/constructor in the class.
View 3 Replies
ADVERTISEMENT
May 27, 2010
I'm trying to extend my new WPF Touch Screen Keyboard (DLL) Library, to allow the user to get events from the Touch Screen Object. I'd like to be able to tell the Programmer what Object made the call (or executed the subroutine) that raised the event. Not dissimilar to the Sender as Object event parameters one gets when working with a System Object. Which begs the question, How do I get that information, if I don't ask for it?Is there a way to get this information from some call made in the subroutine about to raise the event?
View 2 Replies
Mar 31, 2012
I'm trying to extend my new WPF Touch Screen Keyboard (DLL) Library, to allow the user to get events from the Touch Screen Object. I'd like to be able to tell the Programmer what Object made the call (or executed the subroutine) that raised the event. Not dissimilar to the Sender as Object event parameters one gets when working with a System Object. Which begs the question, How do I get that information, if I don't ask for it? Is there a way to get this information from some call made in the subroutine about to raise the event? That would be nice, and a time saver for me.
View 1 Replies
Jul 10, 2010
I am somewhat new to object oriented programming and am attempting to flatten a Linq object hierarchy by using a shim class.how to initalize a derived class with property values from a base class?I have two objects, a base object with about 100 properties, and a derived object which inherits from the base object and adds a few additional properties beyond those of the base object. My simple constructor creates the derived object, but I am looking for a way to initialize the derived object properties with values from the base object.Right now I am using reflection to iterate over the properties individually and I suspect there may be a better way. The following example shows my shim class constructor for the derived class, and two properties:
newProperty1 - a new string property of the derived class
flattenedProperty2 - a new string property of the derived class, copied from a 2nd-level object of the base class
Code example:
Public Class derivedObj
Inherits baseObj
Private _newProperty1 As String[code].......
Is this the correct constructor approach to flatten the object hierarchy using a shim class? My second question relates to initialization of properties in the derived class. The constructor above creates the derived object, but what is the best way to initialize the derived object properties with values from the base object? The following code uses reflection to iterate over the properties individually, but I suspect there may be a better way.
Code example:
' property names are in the string array fieldNames
'baseObjQuery is an ienumerable of baseObj
'derivedObjList is a list of derivedObj[code].....
Is there a simple way to initialize values for the properties in the derived object based upon the values of the common properties in the base object?
View 7 Replies
Jun 1, 2009
This is just a general question, I need help with something on Visual Basic 2008. I do not know why, but as of late every time I open up a project in Vb it gives me something called an object browser. I try to find my forms so I can work on my program, but I can't find them. Has anyone else had this problem or knows how to fix it? I can't get to my forms!!
View 1 Replies
Apr 16, 2011
good tutorials where i can read about the actual object oriented concepts which we use in real time scenarios. Not the "class is a container. fruit is a parent class and apple is a child class" kind of stuff.Recently i was developing a multithreaded GUI application in vb.net and found out many obstacles like using one form's element in another form, changing form property in other class, when to create objects to access elements and many other stuff stumped me.
View 4 Replies
Sep 25, 2011
I'm trying to pick up some simple object-oriented programming skills so I am trying my hand at beginner's problem - and I am totally stuck...I'm trying to write a program that will print to a label, the area and perimeter of your shape of choice, dependent on the Length and Width (for Rectangles and Triangles) or Radius (For Circles) you input and the shape you select.
I know how to do this easily with simple event-driven programming, but I'm trying to do this by using classes and inheritance.The idea I have is that you enter in length/Radius and/or width into text boxes (txtLen, txtWid) and then you can click a button to display the Length, Width and Perimeter or Radius and Circumference, and Area.
I'd create a Super-Class: Shapes to define my overarching parameters - all shapes have area and perimeter. Then I would create sub-classes for each shape inheriting the overarching "Shapes" class - dim'ing all of their respective extra pieces. Then the buttons would display the appropriate info when clicked.I understand this seems like a lot - but really I just need help getting my feet on the ground for this.
View 4 Replies
Jun 18, 2009
Is Visual Basic an Object Oriented Programming Language ?Working as a software engineer
View 2 Replies
Aug 4, 2010
I need to write an program with two players rolling a pair of dice and the highest tally wins with an Game class having with two member variables of the type PairOfDice. I can not get it to work.
[Code]...
View 8 Replies
Oct 28, 2009
Say I want to create a functionTry 5 timesThe function takes a function pointer to another function
function dosomething() as boolean
end function
function tryfivetime (thefunction as what?)
[code].....
View 5 Replies
Apr 20, 2009
i am new to asp and am currently trying to get my head around the visual basic language and Object Oriented Programming.From what i have read you need to have a good understanding of these to create good ASP.NET webpages, but from reading about these in books and joining the website [URL]..i am getting fairly confused with the language and the OOP. Does anyone out there have any tips for me when it comes to learning about these. Is there a good way to learn about these as i just seem to be getting really confused from the start.
View 5 Replies
Feb 24, 2011
I have a ContextMenuStrip that is attached to a DataGridView, how can I change the text of an item in the ContextMenuStrip depending on the value of the cell in which the strip is activated over?
View 1 Replies
Aug 13, 2009
something like this
pctObject.horizontalPosition += 5
I just dont know the right syntax
View 2 Replies
Jan 2, 2011
how to make a collision between the player object and the wall which is a picturebox
i can move the player object (which is also a picture box) with the arrow keys and i've made it move inside the form border, but the porblem is how to make it stop when it touches the wall (picture box) if im moving left and the left border of the player touched the right border of the wall then it should stop and only the up, down and right keys will be working!!!
View 12 Replies
Oct 13, 2008
(Visual Studio 2008 - Visual Basic 2008 - 3.5 .Net Framework) I have few objects on my form and i would to like scan objects' names by my cursor. I wish to get name of object, which is under my cursor. (only one object is under cursor, and form)..
View 2 Replies
Jun 7, 2011
I have few objects on my form and i would to like scan objects' names by my cursor. Bad english, so again: I wish to get name of object, which is under my cursor. (only one object is under cursor, and form)
View 1 Replies
Dec 20, 2009
I have a button named cmd_Grunt and a picture box named pb1_Grunt. I want to click the button and have a picture box created.
"Public Class Form1
Dim grunt = (50)
Private Sub cmdGrunt_Click(ByVal sender As System.Object, ByVal e As
[Code].....
This is the code I have so far. I get an error message, "Expression expected." It wants the expression between "CreateObject" and "('pb1Grunt', grunt))".
ie cmdGrunt_Click(CreateObject HERE ('pb1Grunt', grunt))
View 19 Replies
Jun 29, 2010
I have been learning vb.net for about 6 months now and I red few books about basic visual programming as most to them have information about the basic concepts like what is Object oriented programming, subroutines, functions ,inheritance etc and bit about ADO connectivity to database. Having said all that I think I have good concepts about all these things but now I want to proceed further but can't find appropriate text books or online tutorials.
View 2 Replies
Jan 7, 2010
In a ASP.NET app from a procedure IN a VB code file a dynamic control is called. The first problem may solve the second. In the following line of code I am getting an "end of statement expected" error at the following line.
[Code]....
View 2 Replies
Jul 29, 2011
I am getting following error whenever I want to use IIf function inside entity framework query.
LINQ to Entities does not recognize the method 'System.Object IIf(Boolean, System.Object, System.Object)' method, and this method cannot be translated into a store expression.
View 1 Replies
Apr 16, 2010
What do I need to convert?
Dim CEESearchByAppNo = From CEEsearch In dbCEE.tblScanneds _
Where CEEsearch.AppNo = iAppNo
[code].....
View 5 Replies
May 8, 2009
How do I calculate the direction an object is facing in degrees, if object A is at x1, y1 and facing object B which is at x2, y2?
View 2 Replies
Dec 31, 2009
Occasionally I encountered this exception message while trying to download file from a server using System.Net.FtpWebRequest and System.Net.FtpWebResponse Object.
Download a file.ftpRequest_DL.Method = WebRequestMethods.Ftp.DownloadFile get the response object
Dim ftpResponse_DL As FtpWebResponse = CType(ftpRequest_DL.GetResponse, FtpWebResponse)
[Code]...
View 4 Replies
Oct 18, 2010
If I declare my object at the beggining of my page class, and instantiate it in a dropdownlist selected_index change event. Shouldn't this object be available thru out the entire page and also persist thru a postback? I lose the object in my selected date change event in my calendar.
[Code]...
View 3 Replies
Mar 1, 2012
I have an ssis package that takes a flat file and dumps it to SQL. During that process, 150 columns need to have '-' and '.' removed from them. I have done this using a Script Transformation.
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim column As IDTSInputColumn90
Dim rowType As Type = Row.GetType()
[code]....
Edit I've discovered that this line is the problem
Dim strCol As String = columnValue.GetValue(Row, Nothing).ToString()
View 1 Replies
Oct 16, 2011
I am trying to start the process with the following parameters When I try to start it though I get an System.nullreferenceexception: Object reference not set to an instance of an object
Dim exepath As String = Application.StartupPath + "inffmpeg.exe"
Dim sr As StreamReader
Dim cmd As String = " -i """ + input + """ -ar 22050 -y """ + output + """"
Dim ffmpegOutput As String
[code]....
View 16 Replies
Jan 12, 2011
In the Session_Start of the Global.asax i have
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Session("login") = False
[code]....
Why i am getting error the error Object reference not set to an instance of an object. at line
If Current.Session("login") Is Nothing Then
while checking for the login state as follows?
If GetLogin = False Then
'Do something
End if
I mean i have already created the instance on the Session_Start... Haven't i?
View 1 Replies
Oct 26, 2009
I have an object that is defined as a global variable based on custom class. Within that class I have an event that gets fired a certain intervals. These events are fired on the same thread as where the object is declared. How do I create a global object, but have the events within that object fire on a separate thread?
View 2 Replies
Jan 12, 2010
i am using VB.net 2003 and i am trying to get the number of rows of a dataset from form1 into form2 in order to use it for something else and i am getting the error"System.NullReferenceException occured...Additional information: object reference not set to an instance of an object"...my code is like this:in form1:Public x as integer= me.dataset.table.rows.count here it gives me the error
in form2:
dim frm as new form1
msgbox(frm.x)
View 1 Replies
Jan 5, 2010
I am getting this error when I try to print my report. Here is my print code.
Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
Dim Print_Dialog As New PrintDialog
[code].....
Here is my error: System.NullReference Exception: Object reference not set to an instance of an object.
View 1 Replies