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 1401
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.getupperboun d(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*****@discus sions.microsoft .com> wrote in message
news:BD******** *************** ***********@mic rosoft.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.getupperboun d(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.getupperboun d(0,ms.getupper bound(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_lunch meat_[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.getupperboun d(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.getupperboun d(0,ms.getupper bound(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.getupperboun d(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 driving me mad - here is all the code, sorry it's long
I'd appreciate it so much if someone would tell me why i'm getting
|
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 query :
SELECT DISTINCT TOP @pageSize routeID, routeName FROM
tblRoute_Header
When I attempt to do so I get an error mesage indicating incorrect
|
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 initialize it with the same
parameter. Can this be done with JavaScript? I couldn't find anything in the
documentation. Basically, what I want to achieve is to obtain always the
same sequence of random numbers for the same given initialization...
|
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 details of a random image from an
access database. I know this works because when I run the query in access,
it picks a different image each time (or close enough). However, when I view
the .aspx page that this code-behind is for, it always picks...
|
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 :
doc.LoadXml(EDP.ExportPositions(TextBox1.Text,
cmbStartDateandTime.SelectedText,
cmbEndDateandTime.SelectedText, TextBox2.Text)))
| |
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.
The Form gets created but hangs after creation. I'ts logical that that
happens because the new Form doesn't get a Message Loop.
The Message Loop is created on Application.Run() on the Main Method on the
Main Thread. The Callback is (normally)...
|
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
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
str = "user id=sa;password=;data source=AURO-RA4;initial...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |