Windows - Difference Between (Protected / Partial) And (Friend / Shared) And (Sub / Function) On .NET?
Jun 4, 2012
When I find examples online of VB.NET watch some functions use:
(Protected / Partial) & (Friend / Shared) & (Sub / Function) exp()
End (Sub / Function)
what is the difference?
View 1 Replies
ADVERTISEMENT
May 15, 2009
I can't make difference between public class and private class and friend and protected friend class.
View 1 Replies
Apr 21, 2011
I have extended an Entity Framework 4 entity class with a calculated property in a partial class. This member is not available on the client to which the entities are exposed via WCF RIA Services.when using C# appears to be changing the extension of the partial class file from .cs to .shared.cs. I tried this with my VB.Net solution (.vb to .shared.vb) and got a long list of errors. I believe what happened is that the partial class lost its association with the entity on the client - it inherited from object rather than EntityObject.
My best guess is that this is related to the way that VB.Net handles namespaces.Each project has a 'Root Namespace' which is prepended to anything that is defined within a code file. C# has a 'Default Namespace'which is the namespace into which new types are placed by default - via a namespace statement within the file.The partial class is probably having the client namespace prepended to it which puts it into a different namespace than the entity with which it is associated on the server.Is there any means of extending an entity in such a way that those extensions are available on the client via WCF RIA Services and VB.Net?
View 1 Replies
Jun 18, 2010
Why is it that some components/controls will not be inherited visually in a child form if they are declared with the access modifier Friend vs when they are declared with Protected. For example, I've got a DataSet object in my Parent Form that was initially "Friend" (I drag and dropped it to the form, so it was shown as a control in the designer view), but I noticed that my Child Form did not inherit the control as expected. Once I changed it to "Protected", it showed up in my Child form as expected.I am aware that Protected allows the Child Form to modify the inherited control, but how exactly does this tie in to the issue I described above?
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
Feb 16, 2011
I'm writing a WCF-Service and I split up my service class to multiple partial class files, so every ServiceContract-Implementation gets its own file. I have one file however that should contain e.g. members that are used by every partial class file such as a logger. The service is hosted with IIS 7 if this matters in any way.
[Code]....
The code compiles fine, but at runtime I get an BC30451: The name m_Log is not declared Error (Don't know the exact words for it. I get a german message ;) ). I don't think it has something to do with the type of m_Log or a depending assembly because I get the same error if i try this with a String. What am I doing wrong? How can I make this work? Edit: I was trying the same thing in a simple console application without any problems. :(
View 1 Replies
Jul 7, 2009
I am building archiving system, I store the files on shared folder on windows server 2003, the shared folder protected by one user name and password ,on LAN I need vb.net windows forms to open file inside shared folder, how I could open the shared folder and in same time providing windows server 2003 with user name and password for the shared folder
View 4 Replies
Jul 19, 2009
i have have a few questions about the syntax of the lan.:
1) What is the 'Get' statement and when do you use it?
2) Whats the difference between public, private, protected etc... when declaring functions and subs.
3) When would you use the overrides property?
View 4 Replies
Feb 25, 2011
I'm currently trying to create a NEWID() function in my DataContext in LINQ using the solution here, however, when adding the partial class to my DataContext.vb or a separate DataContextPartial.vb, I get the error System.Data.Function is not available in this context because it is 'Friend'.
I've come across this when accessing data types before and that was in easy fix of setting it to Public, but I'm not sure where the properties for function could be or how to change them.The code I have is converted to VB.NET from the C# in the linked answer above:
Partial Public Class CMSModelDataContext
<[Function](Name:="NEWID", IsComposable:=True)> _
Public Function Random() As Guid
[code]....
View 2 Replies
Jun 22, 2009
exact diff b/t Static v/s Shared variables in VB.NET?
View 3 Replies
Jul 22, 2009
give me a good resource that explains the difference between a Private, Public, Shared Functions/Sub/Variables? I normally use Public for Subs/Functions inside of Modules I call from other parts of the program. But I'd like to get more of an understanding of how and when to use them. I want as little as impact to a system that is running my programs as possible, so i guess the key here is I'm trying to just get more proficient in my coding.
View 8 Replies
Aug 20, 2009
Hi. what is the difference of sleep function and pause function (using timer) between a loop.
View 12 Replies
Jul 2, 2010
When I develop a Windows Forms app in Visual Studio using C#, every control that I add to my form is by default marked as private, which is what I want.
When using VB.NET, every control is by default marked as Friend (the equivalent of internal in C#), which is not what I want.
Can I just change this default? It seems like surely it's a setting somewhere.
View 2 Replies
Dec 16, 2009
is there a difference between shared events and non-shared events?
Private Shared Event EVENT_something_changed()
Private Sub SUB_handles_something_changed() Handles Me.EVENT_something_changed
End Sub
no errors with this code, but how is Me possible since the Event is shared. it seems like there's no errors between switching shared with un-shared and switching Me with Myclass, all 4 combinations seem to work, isn't that weird
View 18 Replies
Mar 29, 2010
I have this class Public Class DGVMod Inherits DataGridView
Protected Overrides Sub OnEditingControlShowing(ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs)
MyBase.OnEditingControlShowing(e)
Try
[Code]...
View 3 Replies
Apr 21, 2011
I've been reading about access modifiers in VB.Net lately, and there is something that I can't really understand: How do elements in a Class (or Module) inherit the modifiers of their enclosing block?For example, suppose you have a Friend class Bla in an assembly, with a public method Foo:
Friend Class Bla
Public Sub Foo
(...)
End Class
Does it behave differently than when Foo is set to Friend?
Friend Class Bla
Friend Sub Foo
(...)
End Class
View 1 Replies
May 28, 2010
I'm writing a .NET CF (VBNET 2008 3.5 SP1) application, which has one master form, and it dynamically loads specific UserControls based on menu click, in a sort of framework idea. There are certain methods and properties these controls all need to work within the app. Right now I am doing this as an Interface, but this is aggravating as all get up, because some of the methods are optional, and yet I MUST implement them by the nature of interfaces.
[Code]...
View 1 Replies
Sep 24, 2009
I have cooked up my first iteration of a code generator which creates the basic Entity models from a SQL Database Schema. Currently, It will scan a SQL Db Schema, and create .vb code files complete with private members and Public property declarations for every User table in the Database. My next step is having it add the basic CRUD procedures as well. Are we mere mortals able to access whatever technology allows the Partial class files created by vs to be hidden/Linked to their "parent" files, such as the Partial Class files for Windows forms or any other designer-generated control? My thinking is that it would be handy to be able to re-generate code files from the database if necessary to reflect changes in the schema, without overwriting any other properties or methods added to a class in addition to those derived from the database. SO I am hoing I can have the Auto-generated output go to a Partial Class file, and then use a regular class file of the same name for the rest of the code. My Concern is the multiplicity of files that might result, so I was hoping it is possible to "tuck them in" to the parent code file in the Class View.
View 7 Replies
Apr 12, 2010
I am having a Friend Class InterceptingChannelBase class.It has a property as below:
Protected ReadOnly Property InnerChannel() As TChannel
Get
Return Me.innerChannelT
[code]....
This class is being inherited by (Friend Class InterceptingInputChannel) class which in turn contains another (Private Class TryReceiveAsyncResult) class.The property above is being used in this private class as below:
Public Sub New(ByVal channel As InterceptingInputChannel(Of TInputChannel), ByVal timeout As TimeSpan, ByVal callback As AsyncCallback, ByVal state As Object)
MyBase.New(channel, callback, state)
[code]....
I am getting the error on the above underlined statement saying that Protected Readonly Property InnerChannel is not accessible in this context because it is declared asa Protected.As far as i think,if i declare a property in class as 'Protected' then if this class is inherited by 'another' class then i can use this property and it should not throw an error.
View 3 Replies
Mar 1, 2011
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?
'1
'the function
Public Shared Function InsertNewRecord(ByVal myStoredProcedure As String) As Boolean
Dim conn As New SqlConnection
[code]....
View 4 Replies
Jul 11, 2009
how to open password protected MS Access database using vb.net windows application?
View 2 Replies
Nov 10, 2011
Dim box As MultiTextBox = New MultiTextBox
Dim i As Integer
for i = 1 to 3 Step 1
lengthWidthHeight = MultiTextBox.GetItemValues()
Next i
This excerpt of code is using the NXOpen API. In the NXOpen API, the MultiTextBox class is public. However, when I compile the code I get the message:
'NXOpen.UIStyler.MultiTextBox.Protected Sub New(ptr As System.IntPtr)' is not accessible >in this context because it is 'Protected'
My question is, how am I getting an error about protected scope? Could it also be that the API documentation is incorrect?
View 2 Replies
Jul 2, 2010
I develop applications in Visual Basic.NET (Visual Studio 2005) for a long time on Windows Vista without problem.
Now, I'm changing my laptop, and the new has installed the Windows 7. So, I reinstalled VS 2005, taking care to install the Vista compatibility. Thus, the version of my current VS 2005 is 8.0.50727.867 (vsvista.050727-8600) SP2. And that is my problem.
When I ran the application in debug mode (F5) on Windows Vista, a windows appeared whenever there was an error, like below:
Now, on Windows 7, the application just shows a exception message in the Immediate Windows, don't showing any error window, continuing the application execution, as below:
View 3 Replies
Jul 2, 2010
I develop applications in Visual Basic.NET (Visual Studio 2005) for a long time on Windows Vista without problem.Now, I'm changing my laptop, and the new has installed the Windows 7. So, I reinstalled VS 2005, taking care to install the Vista compatibility. Thus, the version of my current VS 2005 is 8.0.50727.867 (vsvista.050727-8600) SP2. And that is my problem.When I ran the application in debug mode (F5) on Windows Vista, a windows appeared whenever there was an error, like below: Now, on Windows 7, the application just shows a exception message in the Immediate Windows, don't showing any error window, continuing the application execution, as below [code]
View 2 Replies
May 31, 2009
i am beginner about general programming. Please give me basic shared functions .
I only know few functions such as : Public Shared Function lon(ByVal a As Integer, ByVal c As Integer) As String Public Shared Sub trung()
View 1 Replies
Jan 24, 2011
VB.NET 2010, .NET 4. I am working on an application for controlling an industrial machine composed of many devices attached to the computer. Most if it is reasonable straight forward, but I'm having trouble thinking about the RS-232 devices. One of the RS-232 devices is a fancy power supply with many functions. The ones that are relevant right now are voltage read, voltage write, current read, and current write. The design pattern I'm trying to implement is one in which each attached device is represented by an object that has methods for reading/writing etc and properties for things like COM port etc.
For this power supply, clearly the Port reference should be shared among the instances, so I have a base class (say, PowerSupply) with a Protected Shared Property Port As IO.Ports.SerialPort. Then I have a couple classes that inherit from this class, PowerSupplyVoltage and PowerSupplyCurrent that each define read/write methods and properties for holding the last read/written values. My issue is in parsing the response from the power supply using the Port.DataRecieved event on the shared SerialPort object. The protocol the power supply uses specifies what data it's sending in each response packet.
So, basically, it might say something equivalent to "The voltage is 100V" or "The current is 1A" or "The voltage has been set to 150V" etc. I'm trying to parse this in a shared function. Only during the parsing process would I determine which instance's read/written value to update. I can't access the read/written value properties of the instances from within the shared function. The best I could think of is creating some kind of PowerSupplyCommunicator object that would maintain references to PowerSupplyVoltage and PowerSupplyCurrent instances along with the shared Port and DataRecievedHandler functions.
View 1 Replies
Dec 30, 2009
how I can dynamically load a control inside of a shared/static function?The function itself is inside of a mustinherit/abstract class.(It's an ASP.NET project in VB) I want to do something like this:[code]I'm getting "Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.",but I don't understand this error.I understand what it means, I just don't understand why calling LoadControl isn't seen by the compiler as being an explicit instance of the class. What's not explicit about using LoadControl to create a new control from a file? I tried creating a new user control and initializing it, then setting it to a different control with LoadControl to no avail.I also don't want to do a DirectCast because I'm trying to put this in a shared, mustinheret (abstract) class, which therefore doesn't have an .aspx file to write in a <%@ Reference Control="~/SomeControlPath.ascx" %>, so the class name is unavailable.What I'm trying to do is write a static function that takes some value and returns a control based only on that control's source file location.The end result is a user-modifiable list of controls.They get a column of controls that they freely add, remove, or reorder based on a static list of available child controls that I specify.
View 4 Replies
Feb 16, 2011
I can create classes that use generics, however I was wondering if it is possible to apply this to a shared method rather than rely on the caller casting to the correct type.This is the method:
Public Shared Function DeserializeObject(ByVal serializedXml As String, ByVal givenType As System.Type) As Object
Dim serializer As New XmlSerializer(givenType)
Return serializer.Deserialize(New IO.StringReader(serializedXml))
End Function
I'm pretty sure this can't be done, but thought I'd check (if so Extra points will be awarded if someone can technically explain why the compiler can't do this)..
View 3 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
Mar 29, 2010
xplain to me or give me an example of using a select case in a shared function
View 2 Replies