A subroutine (e.g. procedure or subprogram) is a portion of code within a larger program, which performs a specific task and can be relatively independent of the remaining code. The syntax of many programming languages includes support for creating self contained subroutines, and for calling and returning from them. They are in many ways similar to functions, but usually have side-effects outside of the simple "return value" that functions return.
Questions tagged [subroutine]
1255 questions
-1
votes
2 answers
How to Reference An Event Handler
I want to activate an event handler (i.e. listbox1_selectedindexchanged) in my main subroutine
For example:
Private sub main()
listbox1_selectedindexchanged()
end sub
However, what should I put for parameter "e" and "sender" where e is the…

Fraïssé
- 168
- 11
-1
votes
3 answers
Return multiple variables perl
I have this
sub test
{
my ($arg1, $arg2) = @_; # Argument list
code
return ($variable1, $variable2);
}
So, when i call this by
test('text1','text2');
concatenates the two return values in one. How can i call only one at a time?

Martzy
- 85
- 12
-1
votes
2 answers
Not an ARRAY reference at error in perl script
I'm editing a perl code and I added subroutine to which I need to pass a hash.
%OrigResultHash = Parsing(\%OrigFileHash,\%OrigParamHash);
sub Parsing {
my (%fileHash,%paramHash)=(@ARG);
my %resultHash;
foreach my $file (keys %fileHash) {
…

user1907831
- 1
- 2
- 2
-1
votes
1 answer
Calling subroutine N number of times within a foreach loop
I have the two hash of arrays (HoA) that correspond to the following file:
A 10 15 20 25
B 21 33 21 23
C 43 14 23 23
D 37 45 43 49
Here are my HoAs.
my %first_HoA = (
'A' => [ '10', '15', '20', '25'],
'B' …

cooldood3490
- 2,418
- 7
- 51
- 66
-1
votes
2 answers
Visual Basic - How to send values in a subroutine back to the main program?
I have an assignment in Visual basic I don't know how to do. I am to create 2 sub routines and 1 function that send values back to main calling program. The main program populates the combobox and displays information in the listbox and that is…
user2180070
-1
votes
2 answers
how to use particular external subroutine in Perl
I have a pm file that contains several subroutines. Following is the example of the script "myscript.pm":
sub a();
sub b();
sub c();
a(); #this can not be deleted in my situation in this pm file.
sub a() {
print 'a';
}
sub b() {
print…

Cecil
- 1
-1
votes
1 answer
EXCEL vba subroutine pass letter for range update
i want to shorten this code and i know it's possible i just dont know the proper syntax
i want to create a subroutine to update the font colors and just call it from the if statements by changing just the first cell letter
would someone mind helping…

maxgohan
- 39
- 3
- 10
-1
votes
3 answers
How do I pass a variable through multiple subroutines in perl?
I have a variable currentUser in a sub routine. It carries through to one subroutine, but does not carry through to another subroutine. How can I pass a variable through multiple subroutines while keeping the value?
sub login {
&app_header;
…

RichDiet
- 13
- 3
-1
votes
3 answers
What's the mistake in my recursive subroutine?
This subroutine generates string combinations of the letters using the letters from A to the Mth letter of the Alphabet with length N.
sub genString
{
my($m,$n,$str,$letter,$temp,$i) = @_;
if($n == 0){
$letter = chr(ord("A")+($i+=1));
…

oLraX
- 217
- 4
- 14
-1
votes
2 answers
What is a subroutine and a convenience initializer?
I started learning programming about 8 months ago, started with C, OOP, now onto iOS, which is my goal. Everything is going pretty smooth for the most part and I've started to practice by programming small applications on xcode. It's just little…

Cristian Contreras
- 113
- 1
- 6
-2
votes
3 answers
The user must enter a string that contains at least one lowercase “a”
The user must do the question above or the question keeps repeating so I need a while loop. I need to do this using a subroutine too. My code below isn't working.
public static boolean isAlpha(String name) {
char[] chars = name.toCharArray();
…

Anjola Adejoro
- 3
- 2
-2
votes
2 answers
How do I do the BSR SUBR, and define the SUBR part of the code?
Question
The program is supposed to do the following:
Add up the first 6 data items ($1 to $6) stored at address label DATA.
Store the sum of the first 6 data items to address label SUM1.
Multiply the sum stored at address label SUM1 by 8, and…

thxr
- 1
- 1
-2
votes
1 answer
Can't call a subroutine when within a subroutine, if and for loop. Have I done something wrong here?
So here's my code.
def bubblesort(list):
global step
global oldlist
print("""
ORIGINAL LIST""")
print(list)
for i in range(len(list)):
for j in range(len(list)-1):
if float(list[j])>float(list[j+1]):
…

LewOF04
- 1
- 2
-2
votes
2 answers
Can someone help me fix the error, "There is no argument given that corresponds to the required formal parameter 'num1' of Program.Year (int)
namespace ConsoleApp4
{
class Program
{
public static int Year(int num1)
{
Console.WriteLine("Enter a year.");
num1 = Convert.ToInt32(Console.ReadLine());
if (num1 % 4 == 0)
{
…

anewcoder111
- 1
- 1
-2
votes
1 answer
Creating a subroutine to tell a player when the coordinates that they have entered are already occupied
Ive created a list containing all the coordinates that are available and so my idea is that once a coordinate has been entered it is removed of the list and placed into another list called Taken_Coord.
But I just know my code can be a lot more…

Dylan Jackson
- 21
- 5