View Full Version : Visual Basic
saxotistic
24th November 2007, 15:30
Just wondering has anyone ever used visual basic, if so just wondering if you know how to add up the values in two text boxes and then subtract it from a value from a label thanks.
b0t13
24th November 2007, 15:31
Label2.Caption = Textbox1.Text + Textbox2.Text - Label1.caption ?? not used it for ages!
Luke
24th November 2007, 15:32
Probably best in IT section mate.
Funny you should ask though, I was using it all day yesterday at work programming....have you used Macros before?
MrHouston
24th November 2007, 15:32
I am doing a course on it.. but I can't rememebr xD
Is it VB.Net or VB6?
VTR_Nick
24th November 2007, 15:32
[QUOTE=saxotistic;1645986]Just wondering has anyone ever used visual basic, if so just wondering if you know how to add up the values in two text boxes and then subtract it from a value from a label thanks.[/QUOT
Nope did java scripting in college which is ment to be very similar if i remember correctly
b0t13
24th November 2007, 15:34
from the javascripts ive seen, its completely diff lol
Paul
24th November 2007, 15:40
Hey i used VB6 alot back in college, should of really posted this in the IT section but nvm eh.
You will need a few variables..
Dim labelnumber As Currency
Dim textonenumber As Currency
Dim texttwonumber As Currency
Dim answer As Currency
Private Sub Command1_Click()
Let textonenumber = Text1.Text
Let texttwonumber = Text2.Text
Let labelnumber = Label1
Let answer = textonenumber + texttwonumber - labelnumber
Let Text3.Text = answer
End Sub
There you go mate, you'll need three textboxs, one label, and a command button.
http://i220.photobucket.com/albums/dd172/Paul_CGM/vb.jpg
saxotistic
24th November 2007, 15:40
Label2.Caption = Textbox1.Text + Textbox2.Text - Label1.caption ?? not used it for ages!
gonna try that out now thanks:y:
saxotistic
24th November 2007, 15:46
Hey i used VB6 alot back in college, should of really posted this in the IT section but nvm eh.
You will need a few variables..
Dim labelnumber As Currency
Dim textonenumber As Currency
Dim texttwonumber As Currency
Dim answer As Currency
Private Sub Command1_Click()
Let textonenumber = Text1.Text
Let texttwonumber = Text2.Text
Let labelnumber = Label1
Let answer = textonenumber + texttwonumber - labelnumber
Let Text3.Text = answer
End Sub
There you go mate, you'll need three textboxs, one label, and a command button.
http://i220.photobucket.com/albums/dd172/Paul_CGM/vb.jpg
would it be possible to do it without using a command button, i am doing a marketing section for my assignemnt, so in marketing there are different promotion method so i want the user to enter the amount in % they wish to spend of their promotion budget, then i want something like a label displaying 100% so as the user eneters the % they wish to spend for it decrease it automatically if that makes sense, thanks
Alex
24th November 2007, 15:47
I havn't used VB in ages, but dont you have to type convert between strings and integers using val()?
Paul
24th November 2007, 15:47
oops you mean subtract the values out the textboxes from the label, iv done the label from the textboxs. one minute.
edit,
Well its alot easier using a button, but.. one minute i'll have a quick look.
Alex
24th November 2007, 15:49
Set an event for the textbox (OnChange or OnKeyPress).
saxotistic
24th November 2007, 15:52
oops you mean subtract the values out the textboxes from the label, iv done the label from the textboxs. one minute.
edit,
Well its alot easier using a button, but.. one minute i'll have a quick look.
Yeh sorry, so for example if they want to spend 50% on t.v advertising, then it should deducted it from the label but also if the user decides they want to make the 50% to 40% so the label goes back up by 10% becuase of the change so i want the label value to go up and down based on the numbers the user enters, thanks
Paul
24th November 2007, 15:52
Done a quick 5 minute job here, dont know if it will help.
Dim labelnumber As Currency
Dim textonenumber As Currency
Dim texttwonumber As Currency
Dim answer As Currency
Private Sub Text1_Change()
Let textonenumber = Text1.Text
Let texttwonumber = Text2.Text
Let labelnumber = Label1
Let answer = labelnumber - (textonenumber + texttwonumber)
Let Text3.Text = answer
End Sub
Private Sub Text2_Change()
Let textonenumber = Text1.Text
Let texttwonumber = Text2.Text
Let labelnumber = Label1
Let answer = labelnumber - (textonenumber + texttwonumber)
Let Text3.Text = answer
End Sub
Private Sub Text3_Change()
Let textonenumber = Text1.Text
Let texttwonumber = Text2.Text
Let labelnumber = Label1
Let answer = labelnumber - (textonenumber + texttwonumber)
Let Text3.Text = answer
End Sub
http://i220.photobucket.com/albums/dd172/Paul_CGM/vbedited.jpg
Put the data format for the textboxs to number also. (properties)
edit:
in the screenshot i've forgot to delete the command button.
Paul
24th November 2007, 15:56
Yeh sorry, so for example if they want to spend 50% on t.v advertising, then it should deducted it from the label but also if the user decides they want to make the 50% to 40% so the label goes back up by 10% becuase of the change so i want the label value to go up and down based on the numbers the user enters, thanks
Hmm complicated it now, you want to change the value of the label?
edit
get a screenshot of your work up so i can see what you mean ?
Scattle
24th November 2007, 17:19
I'll post some Visual Basic program soon, ever tried Dev C++ much easier program to use in my opion.
Alex
24th November 2007, 22:55
Delphi or C# is a good start for beginners, Microsoft do a free version of C#.NET
http://www.microsoft.com/express/vcsharp/
b0t13
24th November 2007, 23:41
delphi and c++ are good, but i made my first prog in vB years ago lol.
tbh delphi and vb are pointless knowing in the working world as its old skool now, gd to learn from tho..
TU-Tuning
25th November 2007, 00:07
I had to use this in computing at college. Got bored so spent the whole year making awesome pointless crap and sending it around. Like a thingy that opens and closes the disk try every three seconds you cant turn off. Good times
Paul
25th November 2007, 03:03
I had to use this in computing at college. Got bored so spent the whole year making awesome pointless crap and sending it around. Like a thingy that opens and closes the disk try every three seconds you cant turn off. Good times
*cough* cntrl alt delete *cough*
b0t13
25th November 2007, 03:17
I had to use this in computing at college. Got bored so spent the whole year making awesome pointless crap and sending it around. Like a thingy that opens and closes the disk try every three seconds you cant turn off. Good times
haha i did the exact same thing, and i found code that hidden it from CTL ALT DEL too :)
Alex
25th November 2007, 09:25
haha i did the exact same thing, and i found code that hidden it from CTL ALT DEL too :)
I remember those days "RegisterServiceProcess" :)
Zuton
25th November 2007, 12:24
i failed my programming unit due to a hatred for VB..:P..and the dumass tutor..
b0t13
25th November 2007, 14:21
l337 uber programming skills FTW!
saxotistic
25th November 2007, 14:41
Done a quick 5 minute job here, dont know if it will help.
Dim labelnumber As Currency
Dim textonenumber As Currency
Dim texttwonumber As Currency
Dim answer As Currency
Private Sub Text1_Change()
Let textonenumber = Text1.Text
Let texttwonumber = Text2.Text
Let labelnumber = Label1
Let answer = labelnumber - (textonenumber + texttwonumber)
Let Text3.Text = answer
End Sub
Private Sub Text2_Change()
Let textonenumber = Text1.Text
Let texttwonumber = Text2.Text
Let labelnumber = Label1
Let answer = labelnumber - (textonenumber + texttwonumber)
Let Text3.Text = answer
End Sub
Private Sub Text3_Change()
Let textonenumber = Text1.Text
Let texttwonumber = Text2.Text
Let labelnumber = Label1
Let answer = labelnumber - (textonenumber + texttwonumber)
Let Text3.Text = answer
End Sub
http://i220.photobucket.com/albums/dd172/Paul_CGM/vbedited.jpg
Put the data format for the textboxs to number also. (properties)
edit:
in the screenshot i've forgot to delete the command button.
put all that in to VB but still doesnt work
srcnix
28th November 2007, 13:01
I suggest using a better naming scheme for your variables for a start. You will be marked on naming schemes IIRC.
TU-Tuning
28th November 2007, 13:03
*cough* cntrl alt delete *cough*
Didnt work lol, that was blocked on the system
Alex
28th November 2007, 13:13
It's not as easy as just copy pasting, you have to have the correct controls on the form and set the events to the functions.
Scattle
28th November 2007, 13:14
It's not as easy as just copy pasting, you have to have the correct controls on the form and set the events to the functions.
Yup, I copied a program before and it would not work, some characters can be different so have a check through.
Alex
28th November 2007, 13:34
Yup, I copied a program before and it would not work, some characters can be different so have a check through.
You ripper :P
If you do copy'n'paste remember to set the control events otherwise the code will not be called.
Scattle
28th November 2007, 13:57
You ripper :P
If you do copy'n'paste remember to set the control events otherwise the code will not be called.
Don't normally do it:p but when you have to call a function from an array, I needed some help lol.
Scattle
28th November 2007, 21:08
This is my MP3 Player program that I have to do for my assignment.
Got it to play a song so far, now sorting out the library which is the fun part.
Function 1is the code for playing the file. Have a use if you want.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
FILE *fp;
#define ARRAYSIZE 100
#define SONGNAME 25
#define SONGARTIST 25
#define SONGLENGTH 25
void func1(void);
void func2(void);
void func3 (void);
void func4 (void);
typedef struct Mp3rec
{
char name[SONGNAME];
char artist[SONGARTIST];
char length[SONGLENGTH];
};
int main (void)
{
int menuchoice=0;
//fp= fopen("mp3_list.txt", "r" "W" "a"); either to add or read a text file.
do
{
printf ("********************************************\n");
printf ("****************Steven C********************\n");
printf ("*********** Ruskin Pod MP3 Player **********\n");
printf ("********************************************");
printf("\n1: Play File");
printf("\n2: Show Library");
printf("\n3: Delete File");
printf("\n4: Add Record");
printf("\n5: Quit");
printf("\n\nEnter Choice: ");
scanf("%d", &menuchoice);
switch (menuchoice)
{
case 1:
func1();
break;
case 2:
func2();
break;
case 3:
func3();
break;
case 4:
func4();
break;
case 5:
break;
default:
printf("\nInvalid Choice: 1-4 Only Please");
}
}while(menuchoice!=4);
system("pause");
}
void func1(void)
{
printf("\n\n Play File\n\n");
printf ("********************************************\n");
printf ("****************Steven C********************\n");
printf ("*********** Ruskin Pod MP3 Player **********\n");
printf ("********************************************");
{
char commandarray[ARRAYSIZE];
char mp3filename[ARRAYSIZE] ="C:\\mplayer\\Robin S - Show me Love.mp3";
sprintf(commandarray, "C:\\mplayer\\mplayer.exe \"%s\"", mp3filename);
printf("\nAttempting to Run Command \"%s\"...\n\n", commandarray);
system(commandarray);
int menuchoice=0;
switch (menuchoice)
printf("\n1: Back To Menu");
printf("\n5: Quit");
printf("\nDone.\n\n");
system("pause");
}
}
void func2(void)
{
printf("\n\n Show Library\n\n");
}
void func3(void)
{
printf("\n\n Delete File\n\n");
}
void func4(void)
{
fp= fopen("ListofSongs.txt","r");
printf("\n\n Add Record\n\n");
}
Alex
28th November 2007, 23:19
Interesting doing it in console.
vBulletin® v3.8.2, Copyright ©2000-2025, Jelsoft Enterprises Ltd.