13 Replies - 798 Views - Last Post: 01 August 2013 - 01:39 PM Rate Topic: -----

#1 Kylemontez  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 01-August 13

Simple random in VB?

Posted 01 August 2013 - 12:26 PM

Hello, i have been working on a batch program for three years now, its function is to open a webpage by using the %random% command in place of numbers in the websites URL Ie.
http://www.randomsite.net/view/%random:~-4%%random:~-3%/

what i want to know is how i would write that same code in VB, i have the feeling its simple, but im new to VB and or anything but batch... so odds are im wrong

what the VB program is for is to instead of using a generator to make the code the procedurely open it... i can use a button.

some of the url's finicky details:
1.the number must be 7 digits
2.the number cant start with 0




and before hand im sorry if this post seams unprofessional but i will admit im not a professional and im new to this site, so any help would be relished.

Is This A Good Question/Topic? 0
  • +

Replies To: Simple random in VB?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8915
  • View blog
  • Posts: 33,428
  • Joined: 12-June 08

Re: Simple random in VB?

Posted 01 August 2013 - 12:26 PM

Are you talking VB6 or VB.NET?
Was This Post Helpful? 0
  • +
  • -

#3 Kylemontez  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 01-August 13

Re: Simple random in VB?

Posted 01 August 2013 - 12:31 PM

I have a sneaking suspicion that i have this wrong but i believe it is VB6, the exact program is (Microsoft visual basic express 2012)if that helps in anyway.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8915
  • View blog
  • Posts: 33,428
  • Joined: 12-June 08

Re: Simple random in VB?

Posted 01 August 2013 - 12:33 PM

.NET is .NET.. moving to VB.NET and not VB6.
Was This Post Helpful? 0
  • +
  • -

#5 ybadragon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 177
  • View blog
  • Posts: 1,094
  • Joined: 11-May 12

Re: Simple random in VB?

Posted 01 August 2013 - 12:42 PM

What have you tried thus far in creating a Random number?
Was This Post Helpful? 0
  • +
  • -

#6 Kylemontez  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 01-August 13

Re: Simple random in VB?

Posted 01 August 2013 - 12:48 PM

upon further research i think vb.net although im not sure.
Was This Post Helpful? 0
  • +
  • -

#7 ybadragon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 177
  • View blog
  • Posts: 1,094
  • Joined: 11-May 12

Re: Simple random in VB?

Posted 01 August 2013 - 12:49 PM

It's quite simple to create a Random number in VB.Net. Do you know the maximum number the random number can be?
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8915
  • View blog
  • Posts: 33,428
  • Joined: 12-June 08

Re: Simple random in VB?

Posted 01 August 2013 - 12:52 PM

If you are using VS Express 2012 it is VB.NET.
Was This Post Helpful? 0
  • +
  • -

#9 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3190
  • View blog
  • Posts: 10,677
  • Joined: 12-December 12

Re: Simple random in VB?

Posted 01 August 2013 - 12:55 PM

You need to investigate the Random Class. There is an example further down the page.

This post has been edited by andrewsw: 01 August 2013 - 12:56 PM

Was This Post Helpful? 0
  • +
  • -

#10 Kylemontez  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 01-August 13

Re: Simple random in VB?

Posted 01 August 2013 - 12:57 PM

the numbers absolute maximum would be "11243102" with its lowest being "1"

View Postmodi123_1, on 01 August 2013 - 12:52 PM, said:

If you are using VS Express 2012 it is VB.NET.


Thank you.
Was This Post Helpful? 0
  • +
  • -

#11 Kylemontez  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 01-August 13

Re: Simple random in VB?

Posted 01 August 2013 - 01:08 PM

ok thank for all of yalls help but before i go i have to ask one more thing how do you get the code
Randomize()

Number = Int(Rnd() * 4)


to effect the numbers at the end of the URL... it must seem very newbie of me but... the only thing i can logically think of that would be close is batches
SET /a VAR=-1 

Was This Post Helpful? 0
  • +
  • -

#12 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8915
  • View blog
  • Posts: 33,428
  • Joined: 12-June 08

Re: Simple random in VB?

Posted 01 August 2013 - 01:12 PM

A URL is a string.. convert the number to a string and append it to the URL string.
Was This Post Helpful? 0
  • +
  • -

#13 Kylemontez  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 01-August 13

Re: Simple random in VB?

Posted 01 August 2013 - 01:14 PM

Thanks for all of yalls help. i really appreciate it
Was This Post Helpful? 0
  • +
  • -

#14 ybadragon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 177
  • View blog
  • Posts: 1,094
  • Joined: 11-May 12

Re: Simple random in VB?

Posted 01 August 2013 - 01:39 PM

For formatting your number so it's at least 7 characters long, you will Want to look into String.Format()

This post has been edited by andrewsw: 01 August 2013 - 01:46 PM
Reason for edit:: Added link

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1