I want to display a differnt message evry time a button is clicked. so I set
up a aray of ms(12) so that I can asign 12 differnt strings to a labelbut I
get a error . First of all can I asign a string value to a label? Im new to
vb . I 'm still trying to shake the happits of basica or gwbasic trobo basic.
You get the Idea. So can someone get me on the right path here.
--
//Bart// 4 1376
On Tue, 14 Sep 2004 19:33:02 -0700, Dennis W wrote: I want to display a differnt message evry time a button is clicked. so I set up a aray of ms(12) so that I can asign 12 differnt strings to a labelbut I get a error . First of all can I asign a string value to a label? Im new to vb . I 'm still trying to shake the happits of basica or gwbasic trobo basic. You get the Idea. So can someone get me on the right path here.
Actually, in VB.NET (and VB6 too, unless you had option base 1 set) that
would have 13 items :) But anyway...
Dim ms() as string = {"first", "second", "third", "fourth", "fifth"}
dim rand As new Random()
dim i as integer = rand.next (0, ms.getupperbound(0))
messagebox.show (ms(i))
--
Tom Shelton [MVP]
Additionally to Tom's comments, you say you cannot assign to a label?, the
answer is yes
myLabel.Text = "YourString"
or
myLabel.Text = yourArray(index)
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Dennis W" <De*****@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com... I want to display a differnt message evry time a button is clicked. so I
set up a aray of ms(12) so that I can asign 12 differnt strings to a labelbut
I get a error . First of all can I asign a string value to a label? Im new
to vb . I 'm still trying to shake the happits of basica or gwbasic trobo
basic. You get the Idea. So can someone get me on the right path here. -- //Bart//
On Tue, 14 Sep 2004 21:04:29 -0600, Tom Shelton wrote: On Tue, 14 Sep 2004 19:33:02 -0700, Dennis W wrote:
I want to display a differnt message evry time a button is clicked. so I set up a aray of ms(12) so that I can asign 12 differnt strings to a labelbut I get a error . First of all can I asign a string value to a label? Im new to vb . I 'm still trying to shake the happits of basica or gwbasic trobo basic. You get the Idea. So can someone get me on the right path here.
Actually, in VB.NET (and VB6 too, unless you had option base 1 set) that would have 13 items :) But anyway...
Dim ms() as string = {"first", "second", "third", "fourth", "fifth"} dim rand As new Random() dim i as integer = rand.next (0, ms.getupperbound(0))
messagebox.show (ms(i))
Just to point out one thing. The rand.next function that you show will get
a random number from 0 to 3. It does not include the upper bound. You
need to specify ms.getupperbound(0,ms.getupperbound(0) + 1).
From the docs:
Return Value
A 32-bit signed integer greater than or equal to minValue and less than
maxValue; that is, the range of return values includes minValue but not
MaxValue. If minValue equals maxValue, minValue is returned.
--
Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
In article <zb*****************************@40tude.net>, Chris Dunaway wrote: On Tue, 14 Sep 2004 21:04:29 -0600, Tom Shelton wrote:
On Tue, 14 Sep 2004 19:33:02 -0700, Dennis W wrote:
I want to display a differnt message evry time a button is clicked. so I set up a aray of ms(12) so that I can asign 12 differnt strings to a labelbut I get a error . First of all can I asign a string value to a label? Im new to vb . I 'm still trying to shake the happits of basica or gwbasic trobo basic. You get the Idea. So can someone get me on the right path here.
Actually, in VB.NET (and VB6 too, unless you had option base 1 set) that would have 13 items :) But anyway...
Dim ms() as string = {"first", "second", "third", "fourth", "fifth"} dim rand As new Random() dim i as integer = rand.next (0, ms.getupperbound(0))
messagebox.show (ms(i))
Just to point out one thing. The rand.next function that you show will get a random number from 0 to 3. It does not include the upper bound. You need to specify ms.getupperbound(0,ms.getupperbound(0) + 1).
From the docs:
Return Value A 32-bit signed integer greater than or equal to minValue and less than maxValue; that is, the range of return values includes minValue but not MaxValue. If minValue equals maxValue, minValue is returned.
Yes, your correct... I always forget that. Actually, an easier
solution, would just to use ms.getupperbound(0, ms.length).
--
Tom Shelton [MVP] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jon Whittlestone |
last post by:
hi there.
I am getting two > characters and i really can't understand why they
are there -
see http://www.jonwhittlestone.co.uk/portfolio%20files/wminproperty/landlordAddProperty.php
It is...
|
by: John Morgan |
last post by:
In a 'Top n' type statement I wish to be able to insert the n value
from a parameter, within a stored precedure eg
Having declared @pageSize as a parameter I want to run the following
type of...
|
by: Thomas Mlynarczyk |
last post by:
I remember there is a programming language where you can initialize the
random number generator, so that it can - if you want - give you the exactly
same sequence of random numbers every time you...
|
by: Haydnw |
last post by:
Hi,
I have the code below as code-behind for a page which displays two images.
My problem is with the second bit of code, commented as " 'Portfolio image
section". Basically, the SQL query gets...
|
by: XML newbie: Urgent pls help! |
last post by:
Hi,
I am getting the error: Value of type 'String' cannot be converted to
'1-dimensional array of Long'.
in the following line for TextBox2.Text field :
...
|
by: Roemer |
last post by:
Hi all
I stumbled over a new problem:
I have a programm with just a class that is asynchronous listening for
network connections. As soon as someone connected, a new form needs to be
created....
|
by: ohagna |
last post by:
in oracle form devoloper i tray to connect but get this error mesage :
error mesage NO ORA12636 please what that mean ? ?
|
by: Aray |
last post by:
There were some different type elements. each of the type has arbitary
amount of Elements, and all those Elements is in ramdon order, How Can I
write the Schema file?
|
by: sweatha |
last post by:
Hi Friends
I have designed a form with a label box named 'Label30' and text box named 'TextBox21'. Then I have generated the random number in the label box using the coding in form load event as
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |