Repetitive Statements - Alternative To A Function Or Subroutine?

Jun 15, 2009

Repetitive Statements: Looking for an alternative to a function or subroutine. Years ago, I wrote programs for a company using a language called "Algol", I am sure some of you know of it and but many more do not, it is a pretty old language. It had a capability that I used called a "Define" where you could take a statement (for example x = y + z ) and create a 'define' which was a simple, short replication of that statement. (x=y+z) could be defined as 'mysum'. You could then use 'mysum' any where in the program in place of the 'x=y+z' statement.

[Code]...

Is there a similar type capability in Visual Basic? A sub routine does not satisfy the need unless the variables x, y and z are globally dimensioned to the module? I can do this, but would prefer not to. I am expect there is a similar capability, but I personally have only scratched the surface of the VB capabilities.

View 7 Replies


ADVERTISEMENT

Alternative To Nested Else If Statements With Different Outcomes?

Feb 21, 2012

Is there any better way of handling nested else if statements that have different outcomes?

Here is an example of one of my nested statements to explain:
If My.Computer.Network.Ping(computerName) = True Then
Call InstallVS(computerName)

[code].....

View 2 Replies

Does Subroutine Called By A Function Have To Finish For Function To Proceed

Jun 5, 2011

If a subroutine is called within a function, does the function always wait until that subroutine is completely finished before it will proceed with the rest of the function? If so, is there any way to make it not wait and continue on with the rest of function and not care what happens in the subroutine?

View 3 Replies

Is It Possible To Hide A Public Subroutine / Function

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

Is The Active Function Or Subroutine Name Available At Runtime

Apr 13, 2009

For debugging I've often thought it would be very useful to have access to the name of the fuction or subroutine that is currently executing so that you could print or display this as the code runs. I've been told by some folks that it is not possible, now I'm asking a broader community. Also, when I asked before it was in the context of VB6, now wondering if VB.Net enables access to the executing function or subroutine name.

View 2 Replies

AND Function - Don't Wanna Write Out A Bunch Of If Statements ?

Nov 1, 2010

I don't understand the AND function.

I'm trying to say:

CODE:

It all works, except for the AND part. And I don't wanna write out a bunch of if statements just for this one thing.

View 3 Replies

Gridview Not Have Repetitive Column Names?

Feb 3, 2011

I have to create a report that lists tests that a student has taken and how they answered each question...the column header layout (roughly) looks like:

Test #1 1 2 3 4 5 Test #2 1 2 3 4 5
TestA A B C D E TestB C C B C E

The problem is that the Gridview doesn't seem to like repetitive column names and is renaming the second set of Question #s to something else.

View 3 Replies

Repetitive Image Loads To A PictureBox?

Aug 27, 2010

I am trying to do repetitive loads of images to one picture box. That is: An image is loaded to the picture box from a bitmap image.It is done this way so the image can be scrolled using the mouse.That works fine.The image is loaded from a file.When I attempt to load a second image from a file, I get an error indicating that the resource has not been released.I have tried Dispose() etc, nothing seems to be working.I started with VB 1.0 and worked up through VB6 over the years and am now transitioning to VS 2010. A bit of a neck snapper, but it seems to be worth it.

View 8 Replies

C# - Method To Find / Eliminate Repetitive Strings?

Aug 14, 2011

I am trying to find a solution, in eliminating repetitive string names, say for ex.,in a literal field, i am populating names of the contributor of certain article's history version, and so, if "ron" has contributed to the versioning of an article 3 times, the name "ron" gets added to this literal control, and outputs "ron" 3 times.

View 5 Replies

Suppress Repetitive Number In A ListView Column?

Jan 7, 2010

I have a listview with four columns (category, name, date , amount). More than one items falls in a category and I mark them with a number. ex - different kinds of pens as no.5. So, if I make an entry of five pens, five "5"s shows up in the category column. I want to display only one "5" in the category column and not to make it crowded with same numbers.

View 5 Replies

Program That Will Generate A Pattern Using Do While / If Else Statements / Do Until Statements

Oct 11, 2009

Can someone give me a site to a tutorial that will help me write a program that will generate a pattern using do while, if else statements,and do until statements. I have been using google but I can't find anything. I need to generate patterns a certain size 6 by 6 or similar such as something like a checkerboard but where the ^ symbols is there a suppose to be a blank space..

View 3 Replies

Repetitive Code That References Components Of Main Form?

Jun 10, 2009

I have a lot of repetitive code that references components of my main form. I wanted to create a separate module (correct terminology?) for all this code to be contained. I cut the offending code and pasted it into my new module, changing each label reference, etc to form1.label.click

Form1 was then underlined and I get this message:Handles clause requires WithEvents variable defined in the containing type or one of its base types.I think I'm headed in the right direction, but what exactly am I looking for? Here is a sampling of the code that I would like to keep in a separate place other than Form1.vb:

[Code]...

View 3 Replies

If Statements Inside If Statements?

Mar 14, 2012

I am trying to figure out how to do this:

if (phrase = hello) then
"say hello"
if (phrase = how are you?) then

[CODE]...

So basically, I want it to work like a timeline. If I say hello, then it will respond and move onto the next if statement. Get it?

Here is the code I have now:

If phrase.Result.Text = "hello" Then

synth.Speak("Hello to you too")

If phrase.Result.Text.Contains("How are you") Then

[CODE]...

View 21 Replies

Where Has The Subroutine Gone

May 9, 2010

I am trying to get the hang of this stupid VB.net, but it won't even let me create a subroutine or function, it use to be in the tools menu in VB6. I have spent £50 on 2 books that rabbit on about objects, property's classes etc: but tell me nothing of what I want/need to know, what a waste of money.

View 14 Replies

Don't Understand What This Subroutine Is Doing

Dec 4, 2011

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim d As Integer
Dim price(20) As Double ' Adjusted close price

[code]....

What is the for ... next loops in the second subroutine doing? What is the sim() array meaning?

View 3 Replies

Get X Value Form Another Subroutine?

Jul 23, 2009

Does anyone know how to get x value form another subroutine?

View 3 Replies

Subroutine Triggering Too Soon?

May 1, 2010

I have a form that is bound to a table of data. I have a typical binding navigator. When I go to a different record such as next, previous, first or last I need a subroutine named "LayoutAdjust()" to execute "after" the new next record data is loaded on form. I tried calling the subroutine in the "BindingNavigatorMoveNextItem_Click" action but it executed the procedure before the next record data was loaded

View 1 Replies

Alternative To SQL CE?

Jul 15, 2010

I've created an app (VB.NET) where each installation of the app works with a single local database on the PC. No multiuser and no ability for the user to change databases - the database is effectively part of the app, with a fixed scema, only the data will change.At the moment the database is SQL CE. It has about 30 tables with some simple relationships between the tables.

I'm wondering if there is an alternative to SQL CE that might be faster in this scenario. Although SQL CE is excellent and easy to use, I get the feeling there is perhaps an unecessary overhead when using it for something simple - and it does seem a little slow when my app is doing complex stuff that interacts a lot with the DB. In my prototype I actually loaded the 'database' tables from text files into Arrays and developed subs and functions to perform the database searches etc. It was blindingly fast but I realised it wasn't a scaleable solution because it was an 'in-memory' database. A compromise would be to 'page' data into array when needed, but it all gets horribly complex and that's probably why some very clver people have created SQL CE !

View 3 Replies

Array Passing To Subroutine In VB

Feb 7, 2010

I have an old program written in VB6. I upgraded the program with VB 2008. The updated program works fine except when the program tries to transfer an array to another subroutine. The old VB6 program sends arr(0) as an argument to the subroutine, the address of arr(0) is passed to the subroutine. The array arr() address is the first of a block of consequent addresses one by one, arr(1), arr(2), etc.

Now when running VBnet, the address of arr(0) is not the first of all consequent arr(1), arr(2), etc. It is an isolated number, just like if arr(0) were a variable instead of an array. The addresses of arr(1), arr(2), etc do not exist in the subroutine. [Code]

The variable of y1 passes to the subroutine oK, whilst arr(0) passes also like y1 into an isolated address. So VBnet interprets arr(0) like a variable rather than the first value of a long list. I haven't been able to find out why the above sample does not work. I got stuck in my programming effort, as I cannot proceed to to further development. how the code should be modified to enable the whole array information passing through the subroutine.

View 3 Replies

Asp.net - Call Subroutine From Javascript?

Jun 27, 2011

Problem is, I need to call a VB.NET function from javascript, no two ways around it. This is a bit harder to find.BTW -- Web/Page methods won't work. I have to be able to reference a listbox and it's selected items when the VB code-behind fires.

View 3 Replies

Call A Subroutine By Variable Name (In .Net)?

Jun 21, 2010

what I need to do is to call/run/execute a subroutine using a varaible name from a subroutine.

Public Sub Main(ByVal subName as String)
Call subName ' subName may be contain the value AAA or BBB
End Sub

[code]....

View 5 Replies

Call A Subroutine In An IF Statement?

Jun 16, 2012

I am trying to make a counter go up by 1 every time a subroutine is called But i dont know how to word it. Here is the code. [code]...

View 2 Replies

Ending Application From DLL Subroutine?

Feb 23, 2010

I'm writing a class library and I need to be able to shut down the main code in certain cases.

I know I could raise an event and listen for it in the form called by application.run but I would like to find a way around it.I wouldn't be opposed to try to throw an exception that if unhandled would close the application... but would prefer to come up with a more elegant soln.

View 1 Replies

Execute Subroutine At Startup?

Feb 4, 2011

I am trying to execute the "Data()" subroutine at startup. This did not work:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Data()
End Sub

Is there a way to call the subroutine at the begining of debug?

View 9 Replies

How To Open Form1_Load() Subroutine

Dec 11, 2011

I'm following this tutorial [URL] and it says to Open form1_Load() subroutine. What does this mean and how do I do so? It is really important.

View 3 Replies

Incrementing When Accessing A Subroutine?

Feb 1, 2010

When you access a subroutine by one or more other subroutines each time the variables are zeroed like 'n' below. How can I keep n saved so main can increment n each time.

Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

[Code]....

View 3 Replies

Page_Load Subroutine Is Not Being Called?

Jan 19, 2011

have a look at my VB/ASP code and tell me if you can see what's wrong (I highlighted the important segments in red):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<%@Page Explicit="true" Language="VB" Debug="true"

[Code].....

Basically, I'm trying to get the Page_Load subroutine to execute on the page load, but it doesn't seem to be called. I'm assuming that because I set my feedback label to "feedback" in the Page_Load subroutine, I should see it displayed on the page saying "feedback" on first loading the page and every time I refresh. But this doesn't happen. I'm lead to conclude that the Page_Load subroutine is not being called on the page load.

View 4 Replies

Page_Load Subroutine Not Being Called

Jan 19, 2011

VB/ASP code and tell me if you can see what's wrong (I have bolded the important segments):

[Code]...

View 4 Replies

Pass List To Subroutine?

Jan 24, 2012

How do I pass a list as a parameter to a subroutine? I don't know how to specify the variable type in the receiving routine.[code]...

View 6 Replies

Pass The Value Of Dataset From One Subroutine To Another One?

May 12, 2009

I have two subroutines that consists of two datasets. I am not sure how to pass some data in first dataset named dsGoodStudent to second dataset named dsBestClass.

Private Sub Classification()
Dim SqlSelect As String
SqlSelect = "Select Name, Age, grade from tblStudent where grade = 'A'"

[Code]......

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved