Nested Functions Allowed In VB?
Nov 2, 2009are nested functions allowed in visual basic?
View 9 Repliesare nested functions allowed in visual basic?
View 9 RepliesAre nested try/catch blocks doable/legal/etc? in VB.NET 2003
try
' update statement here
catch sEx as SqlServerCe.SqlCeException
try
[code]....
I am constructing some XML using XML literals. I have a function which returns an XElement.
Function RootElementFormattingFunction() as XElement
Return <Root Data="foo"/>
End Function
In reality it is a bit more complicated than that, but it is called from several places. Now I have linq sequence which generates a set of nodes which I want to make children of the XElement returns
[Code]...
topfunction(myarray, yourarray)
dim function topfunction(byval array1() as integer, byval array2() as integer)
dim function subfunction1(byval array1() as integer)
[code]....
What I am trying to do is have a class where the functions of the same name are both instance functions and shared functions.
Public Shared Function Get...(byval xx as xx)
and
Public Function Get...
The Public Function uses a Property xx created in the constructor, whereas the Shared Function has the parameters (byval xx as xx).
so far i got
code
For Each item As Reflection.FieldInfo In GetType(NameSpace.ClassWithNestedClasses).GetFields
rtfAppend(item.Name & ":" & Tab & item.GetValue(Me))
Next
For Each item As Reflection.PropertyInfo In GetType(NameSpace.ClassWithNestedClasses).GetProperties()
[code]...
which gets me the simple string vars and properties of my top class, but how can i apply this to loop through all sub classes and get there vars and props?
1) Is it possible to access the Excel mathematical functions without actually opening Excel?
I was thinking of through a DLL WinAPI call or maybe a delegate function or smaller program?
2) Does anyone know of a MS link or area that gives instruction on "how to" use every function of every Windows DLL at all?
Or for all those that Microsoft have chosen to document online at least.
While converting types, I have found myself using both VB functions and BCL Convert.To* methods.
E.g.)
Cstr() vs. Convert.ToString()
CInt() vs. Convert.ToInt32()
CDbl() vs. Convert.ToInt64()
etc...
Are there any subtle differences that should be noted?
Is there a way to see exactly what the functions are doing. What i mean is there a way to see the class? I know what it does, i just want to know the code.
For example the function: Membership.FindUsersByName()
I have a problem when trying to send a POST request. The sending method looks like this:
Public Sub SendXML(ByVal file As String)
Dim reader As New StreamReader(file)
Dim data As String = reader.ReadToEnd()
[Code]....
Now looking at this I suspected that it was due to the fact that the server does not accept POST messages. But some other reading suggests that the the URI [URL] has been generated with a proxy and should be /Request so the line should read POST /Request HTTP/1.1
So what would be the common reason for this? And if it is a proxy problem, how is it sorted?
As asked below, I have created a new question for the more specific request. Changing absolute URI to relative in HTTP POST header
I know that you cannot specify a constructor in an interface in .Net, but why can we not?
It would be really useful for my current project to be able to specify that an 'engine' must be passed in with the constructor, but as I cant, I have to suffice with an XML comment on the class.
i am currently having two problems with this assignment. The program allows the user to add new students to a listbox with a unique Id, lastname and test average. When adding a new student to the listbox, part of the assignment is to not have duplicate students added. I am currently stuck at trying to figure that out. I have figured out how not to have duplicate courses under the course information form but when trying similar code for adding a student i cant get anything i try to work. the next problem is when searching for a student from the list and clicking on the Course Information button, the course information added for that student needs to be displayed. My problem is getting the student searched information to show up right, but if i add three students and search for the first one i added and click on course information button it only shows the last student i added. this is my code for the whole program
Public Class Form1
Private allStudent As New List(Of Student)
Private currStudent As Student
[Code].....
I got this Error : Reference to class 'ApplicationClass' is not allowed when its assembly is linked using No-PIA mode.
This Is My Code:
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Reflection
Imports System.Threading
[Code] .....
When I installed Visual basic 2008 express edition it seemed to work, but when i was going to make a project it pups up a error box and it says: Regestry it not allowed.
View 2 RepliesI'm trying to declare name of the string to be same value as that string.For example:
Dim x As String = x
Quote:
Originally Posted by ERROR MSG
[code].....
I am assuming "No", but I cannot find conclusive proof on Google to back this assumption. Using keywords of 'vb.net "generic operator overload"' yields exactly 1 result, and removing 'overload' gives more, but no direct statement to the issue.
My thinking is given an abstract class, it'd be great to be able to implement a generic operator overload that a derived class can use in such a case when said operator overload has to return a New copy of the derived class, yet the code for each overload is the same. If that makes any sense.
This touches back to my previous questions on my custom Enum class and overloading the bitwise operators (And, Or, Not, & Xor), but, this particular thought was prompted by a mere curiosity of "Can it be done?".
Here's what one of my custom enums basically look like:
The parent, EBase is nothing special, just hosting common Name and Value properties, plus two shared operators, op_Equality and op_Inequality.
Friend NotInheritable Class EExample
Inherits EBase
Private Sub New()
[Code]....
Then (in theory anyways), calling EExample.OneA Or EExample.FiveE would work because the compiler would know to call the generic operator overload from EBase, know that EExample.Enums matches the IEnums interface constraint, and automatically supply T.
That or I'm just swimming up a certain creek here without a paddle and over-analyzing things. But it's an interesting thought, no? What is StackOverflow's consensus? Do I need to lay off the Spice a little bit?
PS: I use /* */ style comments because Markdown doesn't handle VB-style properly.
PPS: I know that, in the last example, Return New T( ... ) is invalid, but I can't think of a proper syntax that would articulate the basic idea.
How can I check for characters not allowed for file creation programmatically? you know like the / <> and so.
View 3 RepliesI am getting an error "Operation is not allowed while object is closed". On this line of code "Do While myRecSet.EOF = False" here is all my code. First the module/function
Code:
Module Module1
Public coater As String
Public myQuery As String
Public myRecSet As New ADODB.Recordset
Public Conn As ADODB.Connection
[Code] .....
I just tried to build my application by pressing "Shift"+"Ctrl"+"B", and I got this error.
Error 1 Dialog Module 'AdminProgressForm' is not allowed in group 'End' C:Documents and SettingsITWONMy DocumentsVisual Studio 2005ProjectsHRMSHrmsSetupHrmsSetup.vdproj HrmsSetup
I am creating an login page connected to a database. I am using access ODB. the problem is, if the user makes an wrong input, and the invalid data message box appeared, when typing the data again, and press ok, the following exeption occured:Not allowed to change the 'ConnectionString' property. The connection's current state is open.[code]
View 3 RepliesFollowing is the code for inserting new nodes in an xml file .
Dim fleStream As New FileStream("C:mailing.xml", FileMode.Append, FileAccess.Write,FileShare.ReadWrite)
Dim stmWriter As New StreamWriter(fleStream)
[Code]....
When i open the xml file the datas are entered, What modifications are to be done in my code?
is the insert of my code to close a form and it happens to be that when i click on the close button it gives the error "Operation is not allowed when the object is closed"and highlights the adoPrimaryRS.Close() line.
View 7 RepliesI am using an ADODB connection to a Sybase ASE Database for a small app that runs queries and returns the results to a grid, to XML and to Schema file. I recently tried the query on a Sybase script (Between a Begin and End statement) and had an exception when I used RS.EOF which reported "Operation is not allowed when the object is closed." The code works fine for other queries, including those between begin and end statements, so I did some debugging and found that the failure only happens when my SQL script (Which is typed into a rich text box) contains either Sybase variables (ex. @MyTable) or uses temp tables (ex. Select * into #mytemptable from myrealtable). The actual execution works OK (without an exception) but the recordset seems to be closed. A failing example is :
Begin
Declare @Name Varchar(30)
Select @Name = "MY_TABLE"
[Code]....
Im trying to take fields from a Products Table and populate a listbox in a userform with the productName field. that works fine. but i also have to open the recordset and the connection. when i run the program, i get an error saying the 'operation is not allowed when the object is open' then it highlghts the bolded line in the following code:
Sub testc()
Dim SQL As String
SQL = "SELECT ProductID, ProductName, RetailPrice, QuantityOnHand " _
[Code]....
how can i get rid of the error? and what is the problem? i've tried closing the recordset in various places in different subs but nothing works. .
I am writing an application in Visual Basic .NET requiring Registry access.Whenever I try to read from the registry, I receive the following error message:"Requested registry access is not allowed"
View 3 RepliesI had a submit button,when i click the button,it will verify that the textbox1 is only allowed string input.How can I do so??
View 7 RepliesI had a submit button,when i click the button,it will verify that the textbox1 is only allowed string input.How can I do so
View 7 Repliesurl...If a base class has a members, say a property, that you do not want exposed through the inheriting class then it appears to be not possible (at least with VB.NET) to fully remove the member so that consuming code of the inheriting class has no awareness of that member at all.I know there are ways to make it less prominent or to shadow it so that its functionality or appearance has been altered, but I'm just talking full removal all together.So my questions are:
1)Is my assumption correct (for VB.NET but I'd also like to know which languages do allow for this technique)?
2)(more importantly) What is the driving principle in OOD that supports this restriction?
My guess on question 2 is that inheritance is fundamentally about extensibility rather than the opposite (what is that word anyhow?).I suppose a base class should be protected so that the original intention is not changed so much as to be radically different.At that point one shoudl make a whole new class.But is there a principle behind such reasoning, if true?And is it really a "sin" to want to completely remove only one of a hundred members to essentially tweak the look or feel of that class?I can live with this restriction, but it has peaked my curiosity and I'd like to hear from others on the subject.For the sake of discussion here's a sample class try to make an inheriting class (multiple inheritance is okay too) in which DataSource is notvisible or usable under any condition.[code]
This does not compile. Dim Tom As New List(Of String) = {"Tom", "Tom2"} This does Dim Tom As String() = {"Tom", "Tom2"} IMO this features should be allowed for all collection types and not only arrays.
View 2 RepliesI'm redoing a program for my company and my boss wanted me to created the entire thing through functions...
For the task I wanted to know is it possible to have functions within functions?
Sort of like in C where we would have nested structures?
Its a FILE I/O, with robot commands, moves and verifications....
So I would find the line in an excel spreadsheet where it moves, the coordinate, put it into an array.
Take the actual results store them into a two dimensional array...etc, etc....
Another function would eventually compare the results with the moves, and within a tolerance.