answersLogoWhite

0

📱

Visual Basic Programming

Visual Basic programming involves the use of a language that allows programmers to create simple and complex applications. It is a combination of visually organizing components or controls, specifying their attributes and actions, and writing additional codes for better functionality.

903 Questions

Why does graphical user interface programming often use event driven programming paradigm?

It's not a case of often, but always. Whenever your application is idle the application's idle loop is executed. By default, the idle loop simply processes system messages which may result in your application becoming active. For instance, as you pass the mouse over your application window, the operating system generates and posts hundreds of mouse movement messages which are passed to the message queue. The application's idle loop will process these messages and call the appropriate event handlers. Mouse movements may not be relevant to your application but they must be processed nonetheless. When the message queue is empty, the idle loop begins background processing. By default this does nothing except peak at the message queue looking for new messages for your application, but it can be overridden to perform any tasks that take your fancy (such as housekeeping tasks).

However, when the user clicks an object in your window (such as a command button), you would rightly expect your application to respond to that particular event. Thus the appropriate event handler is executed and control eventually returns to the idle loop again.

Problems occur when the event handler executes a highly-intensive task and therefore cannot yield control to the idle loop. This isn't a major problem if the task would only take a few seconds at most to complete, but if it takes any appreciable time this presents a serious problem. If your application does not process messages that are intended for it, then those messages will prevent other programs from gaining access to their messages. And as the message queue fills up, the system, grinds to a halt. Higher priority messages will still get through but the system will quickly become unresponsive.

To address this problem, your application must provide a user-defined message handler that can be periodically called by your intensive tasks, preferably two or more times every second to keep the system as responsive as possible. This message handler needn't be complex, but it must return a value to the caller to signal if the caller should abort or continue processing. For instance, if the user chooses to shut down the system mid-process, your intensive task must be able abort gracefully before the application itself can exit gracefully. This means your message handler must save and remove the message from the queue and signal the process to abort. The message handler may be called several times before the process finally aborts, but when it does control can pass to the idle loop which will finally deal with the message that caused the abort, thus permitting a graceful exit.

Tools used in visual basic and their meaning?

Given the fact there are around 50 default controls provided within the toolbox of visual studio, each with a highly in depth range of properties, events, methods and parameters you should probably focus your question on which individual tool you wish to know about.

It is probably possible to write an eight page laymans description for each control and it's uses accross the vb spectrum, and that would be without delving into the newer WPF uses of, say, a ListBox.

What is the Difference between combo box and list box in visual basic?

  • LISTBOX CONTROL

    COMBOX CONTROL

    A LISTBOX CONTROL displays a list of items from which theuser can select one or more. If the number of items exceeds the number that can be displayed, a scroll bar is automatically added to the List Box control.

    a list box is appropriate when you want to limit input to what is on the list

    choices not on the list can be typed in this field.

    A COMBOX CONTROL combines the features of a text box and a list box. This control allows the user to select an item either by typing text into the combo box, or by selecting it from the list.

    a combo box is appropriate when there is a list of suggested choices

    A combo box contains an edit field.

Write a VB program for binary search?

The optimal binary search algorithm uses a sorted array as the data container. Define the range to be searched using a half-closed range of indices [begin:end). Initially, this will be the half-closed range of the whole array.

The algorithm is as follows:

If begin>=end, this would indicate the range is empty or invalid, thus the value cannot exist. We return the end iterator to indicate value not found.

If the range has one or more elements, then we calculate the middle index of the range:

middle = begin + (end - begin) / 2

Note: division takes precedence over addition.

We then compare the value in the middle of the range with the value being searched. If they are equal, we are done, we simply return the middle index.

Otherwise, if the value being searched is less than the middle value, we adjust the upper bound of the array so the next iteration only searches the lower half of the original range:

new_end = middle

Otherwise we adjust the lower bound of the array so the next iteration only searches the upper half of the range:

new_begin = middle + 1

We then repeat the algorithm using the adjusted half-closed range.

The algorithm can be implemented in Visual Basic as follows. Note the array, a, is passed by reference (ByRef) to prevent making an unnecessary copy of the array. The function does not make any changes to the array itself so there's no need to copy it.

Function bin_search (ByRef a As Integer(), ByVal begin As Integer, ByVal end As Integer, ByVal value As Integer) As Integer

' save the end iterator (it may change later)

Dim not_found As Integer = end

' while the range is valid...

While begin < end

' calculate middle index

Dim middle As Integer = begin + (end - begin) / 2

' compare the middle element for equality

If value = A[middle] Then

' value found!

Return middle

End If

' value not found, so determine which half of array to eliminate

If value < A[middle] Then

' eliminate upper half (if value exists, it must be in the lower half)

end = middle

Else

' eliminate lower half (if value exists, it must be in upper half)

begin = middle + 1

End If

' repeat algorithm...

End While

' if we get this far, the range is either empty or invalid (begin>=end), so the value does not exist

Return not_found

End Function

What is combo box?

A combo box is a list of multiple values a user can select. Sometimes we refer to them as dropdown lists. When you click on it a list of value pops down and you can choose an option. They are very commonly seen on computers. To create them you use the Combo Box control in Visual BASIC.

What are the steps involved in creating visual basic programs?

The traditional way to learn any programming language is to start by writing a "Hello, World" program; this program should write "Hello, World" to the screen. To write such a program, you have to work out how to edit text, and run it through the compiler. Visual Basic, is almost like that, but window environment programs are event driven - they consist of routines that react to events - a button being clicked, a timer expering and so on. Visual Basic is also object orientated. Windows, buttons, every component of a program are objects or part of objects. With this in mind, its useful to read up on events and objects to see how to approach Visual programming. With a little knowledge, think of a project and try and write a program. Writing programs is by far the quickest way to become proficient in a language.

Write a VB program in to find number is Armstrong or not?

Private Sub Check_Click()

Dim d As Integer

Dim num As Integer

Dim s As Integer

Dim old As Integer

num = Val(Text1.Text)

old = num

s = 0

While num > 0

d = num Mod 10

s = s + (d * d * d)

num = num \ 10

Wend

If old = s Then

Label1.Caption = "Armstrong"

Else

Label1.Caption = "Not armstrong"

End If

End Sub

What are the advantages of a computerised library system?

So that the information can be managed easily, and retrieval, storage and modification can be done easily and in a faster way .

The redundancy can also be reduced ........

What is module in visual basic?

Answer

A key part of developing applications using Visual Basic is ensuring that the code is carefully structured. This involves segmenting the code into projects, modules and procedures so that it is easy to understand and maintain.

A complete Visual Basic application is typically contained in a single project. Within a project, code is placed in separate code files called modules, and within each module, the Visual Basic code is further separated into self contained and re-usable procedures.

Write an algorithm for bisection method?

#include[stdio.h]

#include[math.h]

#define epsilon 1e-6

void main()

{

double g1,g2,g,v,v1,v2,dx;

int found,converged,i;

found=0;

printf(" enter the first guess\n");

scanf("%lf",&g1);

v1=g1*g1*g1-15;

printf("value 1 is %lf\n",v1);

while (found==0)

{

printf("enter the second guess\n");

scanf("%lf",&g2);

v2=g2*g2*g2-15;

printf(" value 2 is %lf\n",v2);

if (v1*v2>0)

{found=0;}

else

found=1;

}

printf("right guess\n");

i=1;

while (converged==0)

{

printf("\n iteration=%d\n",i);

g=(g1+g2)/2;

printf("new guess is %lf\n",g);

v=g*g*g-15;

printf("new value is%lf\n",v);

if (v*v1>0)

{

g1=g;

printf("the next guess is %lf\n",g);

dx=(g1-g2)/g1;

}

else

{

g2=g;

printf("the next guess is %lf\n",g);

dx=(g1-g2)/g1;

}

if (fabs(dx)'less than' epsilon

{converged=1;}

i=i+1;

}

printf("\nth calculated value is %lf\n",v);

}

What is the general problem encountered in sales and inventory system?

The most common issues encountered are maintaining an accurate inventory. There is always an issue reconciling stock in and stock out as a miss count on delivery can throw the system a curve ball. Dealing with return of a product also has its issues as stock needs to be either be- returned and can go back in to the selling/supply route or returned and is not of a quality which will allow the product top be placed in the selling/supply route. However, this is frequently where miscounts occur as there is no track of the item once returned. Good inventory will allow the product to be - (a) scrapped and removed from site (b) Scrapped and awaiting removal to xyz destination - This is particularly important as many countries are now requiring organisations to monitor record and report waste disposal so recording this in an inventory systems is especially useful.

To balance the system it is also a positive to undertake mini stock counts on product groups, normally on a weekly basis this ensures that over a period of time stock holding is checked and accurate records made - Changes in volumes are them made as the year progresses. When a full audit is taken there are less major issues - Whilst this is a good practice many organisations fail to budget the process in and this leads to a poor accounting of the system - From a Sales perspective undertaking the aforementioned keep the sales team more informed - However, if you deal with date related products like food the it is even more essential that monitoring of stock rotation is observed as its a failing in many good company's even that staff will place lower coded products at the bottom/at the back of the storage area thus causing lost revenue and more importantly very unhappy customers who get the low and out of code products and the end of the supply chain.

Slot allocation is a very important factor within any inventory system. This is where a product is placed for the storage awaiting transfer to sales. In some circumstances a product, because of a high holding requirement may over spill to other areas of the storage area. These are missed and give the impression of lower stock levels than actually are there - again a good system will be able to have multiple storage locations associated with the products.

How do you open a project in Microsoft visual studio 2008?

Making sure that it is a 2008 project or earlier you go to open project then find the file on your computer. Double click it an d it will open (if it is older then 2008 it will ask for you to convert it first)

Importance of programming in system development?

When business organization facing a keen (鋒利的) competition in the market, rapid change of technology and fast internal demand, system development is necessary. In the system development, a business organization could adopt the systematic method for such development. Most popular system development method is system development life cycle (SDLC) which supports the business priorities of the organization, solves the identified problem, and fits within the existing organizational structure. When business organization facing a keen (鋒利的) competition in the market, rapid change of technology and fast internal demand, system development is necessary. In the system development, a business organization could adopt the systematic method for such development. Most popular system development method is system development life cycle (SDLC) which supports the business priorities of the organization, solves the identified problem, and fits within the existing organizational structure.

What are the parts of Visual basic.net?

Visual basic is a programming language from Microsoft. Some of its parts include data access objects, ActiveX data objects, and remote data objects. Their function is to provide access to databases.

What are the VB built in data types?

Visual Basic.net 2008 Datatypes

Data Type in Visual Basic.net 2008 defines the type of data a programming element should be assigned, how it should be stored and the number of bytes occupied by it.

In VB.net 2008 all the variables by default are of Variant datatype was used for numeric, date, time and string data, but in VB.net 2008 Variant and Currencydatatypes are no longer available. Following are the common data types used in Visual Basic.Net 2008.

Data TypeValue RangeByte0 to 255BooleanTrue or FalseChar0 to 65535DateJanuary 1, 0001 to December 31,9999Decimal+/-79,228,162,514,264,337,593,543,950,335 with no decimal point; +/-7.9228162514264337593543950335 with 28 place to right of decimal.Double-1.79769313486231E+308 to -4.94065645841247E-324 for negative values to 4.94065645842247E-324 to 1.79769313486231E+308 for positive values.Integer-2,147,483,648 to 2,147,483,647Long-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807ObjectAny type can be stored in a variable of type ObjectShort-32,768 to 32,767Single-3.402823 * 103 to -1.401298 * 10 45 for negative values 1.401298 * 10 -45 to 3.402823 * 10 38for positive valuesString0 to approximately 2 billion characters

What is the history of Visual Basic 6.0?

Visual Basic was first released in 1992 Visual Basic was first released in 1998. This version included the ability to create web-based applications. Support for this version ended in 2005.

Write a program to enter the numbers till the user wants and at the end it should display the count of positive and negative and zeros entered?

#include <iostream>

#include <cstdlib>

using namespace std;

int main()

{

int count =0;

int sum = 0;

int positivecount = 0;

int negativecount = 0;

double average;

cout <<"Enter any integer or enter 0 to exit ::";

cin >> count;

while(count != 0)

{

sum += count;

average = sum / static_cast<double>(count);

count++;

if(count < 0)

{

negativecount++;

}

if (count > 0)

{

positivecount++;

}

cout <<"Enter any integer or enter 0 to exit ::";

cin >> count;

}

cout <<"the average of the numbers is " << average <<"\n";

cout <<"There are " << negativecount <<" negative numbers\n";

cout <<"There are " << positivecount<<" positive numbers\n";

system("pause");

return 0;

}

by rijaalu

Two pre-defined functions in visual basic?

A string is a line of text.

For example:

Dim example As String = "whatever text you want"

Would make a string that says "whatever text you want"

Later, you can use this for a msgbox or textbox

Example:

TextBox1.Text = example '(that is the string we made)

or

MsgBox(example, MsgBoxStyle.Information, "Note!") '(would display a msgbox containing the text in the string)

What are the objectives of visual basic 6?

It is not just a language to program in but a whole graphicaldevelopment environment. This aids your programming skills allowingyou to concentrate on developing novel ideas instead of going over oldground.

How do you write an assignment statement in visual basic?

You declare it by this:

Dim var as integer

or

Public var as integer

You can use other types instead of integer like long, double, string, byte etc.

Using Public is for making a variable accessible from everywhere and using Dim is for making it accessible only from where you declared it from.

For using the variable you just type:

var = 1

var = "something"

var = 5 + 10 * (2 - 3)

var = var & "abc"

var &= "abc"

In each case the variable will have these values:

1

something

-15

Whatever var had before plus abc

Again whatever var had before plus abc

These are the basics of using a variable

Write a program to print sum of the digits in the given number?

The following function will sum the digits in any positive number.

unsigned int sum_digits(unsigned int num, unsigned int base=10)

{

sum=0;

if(base>1) // base must be 2 or higher

{

while(num)

{

sum+=num%base; // add least significant digit to sum

num/=base; // shift right by base

}

}

return(sum);

}

Difference between event driven programming and traditional programming?

In traditional programming, code was run from start to finish and sometimes asked for input along the way. Event driven programming, on the other hand, does nothing until it gets an event, such as a mouse moving or a key being pressed.

What is a code window in visual basic?

The Project Explorer tree view consists of the following node types:

  • The root project node is always named after the project and lets you add folder and file items to the root folder of the project.
  • The Documentation Sources node is where you will specify the assemblies, XML comments files, and/or solutions and projects that go into the reference (API) content of the help file.
  • The References node is where you specify dependent assemblies that provide base class information for the documented assemblies but themselves do not appear in the help file's table of contents.
  • Folder nodes can be created to organize the file content of the project.
  • File nodes represent conceptual content topics, images, content layout files, and various other supporting files that may or may not be compiled into the help file. Each file has a build action that determines how it is handled during the build process.