SEARCH YOUR SOLUTION HERE  

(Non Repeating) Random Numbers in VB.Net



I can not seem to receive used to using arrays in VB.Net. On the code snippet behind page I want to select a random number b/w 1 and 25. That's simple enough: Dim myVal As Int16 Randomize() myVal = Int((Rnd() * 25) + 1) Next, I want to make sure the same random number
does not come up again. What is the best way to do this I am thinking given bellow: 1. Use an array that holds the values of all earlier created random numbers. 2. Check in the array to view if a number has been created, if it has, either add or subtract
one from the current number. The difficulty is, I can not figure out the syntax. Id applaud if somebody could post a sample of (or link to) identical syntax. Also, if there is the best way to do this, pls let me know.
Posted On: Wednesday, November 7, 2012 Total Views: 3
View Complete with Replies




Related Messages:

reference to a non shared member requires an Object reference   (7 Views)


Hello
I have the following code snippet below, how the line where it says : For Each c As councillor In councillorList i receive the error message: reference to a non shared member requires an Object reference. Can somebody pls suggest where I'm going wrong
PublicClasscouncillorsPropertycouncillorListAsNewList(Ofcouncillor)
PublicClasscouncillor
PropertycouncillorIDAsInteger
PropertyTitleAsString=""
PropertyForenamesAsString=""
PropertySurnameAsString=""
ReadOnlyPropertyfullnameAsString
Get
ReturnString.Concat(Forenames,"",Surname)
EndGet
EndProperty
SubNew()
EndSub
SubNew(ByValcouncillorIDAsInteger)
councillorID=councillorID
Callgetcouncillor()
EndSub
Subgetcouncillor()
ForEachcAscouncillorIncouncillorList
Ifc.councillorID=councillorIDThen
Me=c
EndIf
Next
EndSub
EndClass
View Replies !
How do I send anonymous Email like craigslist?   (12 Views)


I'm creating a program and wanted to generate an E-mail function like thatof craigslist. For those not familiarwith craigslisthere is anexample.
When an item is listed for sale an E-mail addressis created and assigned to the item. Some thing like
sale-abcd-12345@craigslist.com. I assume tare using some sort of E-mail catchall that than maps the temp email id to the real one and sends.
I can not find one example of how can i do this on a windows machine using .net. Any assistance would be extremely comprehended. An email component would good too.
View Replies !
Index was out of range. Must be non-negative and less than the size of the collection.   (12 Views)



.netCHARTINGSample
SubPage_Load(ByValsenderAsObjectByValeAsEventArgs)'setglobalproperties
Chart.Title="2002Sales(mouseoverforsalesamount)"
Chart.Size="600X300"
Chart.TempDirectory="temp"
Chart.Debug=True
Chart.YAxis.FormatString="c"
Chart.NoDataLabel.Text="Clickasalespersonsyearlytotaltoviewabreakdownbymonths"'forceverticalchartarealayout
Chart.ChartAreaLayout.Mode=ChartAreaLayoutMode.Vertical'CreateaDataEnginetoobtaindatafortwodifferentseries
DimdeAsDataEngine=NewDataEngine()
de.ConnectionString=ConfigurationSettings.AppSettings("DNCConnectionString")
de.StartDate=NewDateTime(2010,12,1,0,0,0)
de.EndDate=NewDateTime(2010,12,31,23,59,59)'getaseriesforthedefaultchartareaandsetitsurlfordrilldown
de.SqlStatement="SELECTCNTR_OP,sum(Total)FROMtableWHEREDISC_ATB>=#STARTDATE#ANDDISC_ATB=#STARTDATE#ANDOrderDate0Then
DimiAsInteger
Fori=0To(sc(0).Elements.Count)-1
Ifsc(0).Elements(i).Name=enThen
sc(0).Elements(i).Color=Color.Yellow
EndIf
Nexti
EndIf'Addthenewareatothechart.
Chart.ExtraChartAreas.add(ca2)EndSub



View Replies !
putting carriage return line feed in non-HTML Email text   (10 Views)


Using vb.net asp.net 2005
I am attempting to generate a string message for an E-mail that I am sending out from my asp.net page like so: ForEachdrIndtDataTable.Rows
strMessage=strMessage&vbCrLf&vbCrLf&Environment.NewLine&dr.item("UserName")&Environment.NewLine Next
so I am looping by a datatable and getting each name from each row that is working well but when I receive the E-mail it appears in my inbox with all the names mashed together, u view I am attempting both vbcrlf and newline but looks like neither is working
does anybody know what I am doing wrong
View Replies !
Using Anonymous types and assigning values to controls or attributes   (3 Views)


I'm attempting to generate a website that users can log into andself serve their user info ie nameaddress and more. I have set up a SQL server Database with a couple of table holding the data and accessing those using Linq. I'mselecting specific data from my datacontext
then attempting to assign it to a label, ideally I need to assign the value to a class attribute so I can use the users details on more than one pages.
I've simplified the code snippet (removing WHERE statement and more for the purposes of this question):
Using CurrentUserDataContext
As
New UserDataDataContext()
Dim UserData = (From LG_User
In CurrentUserDataContext.LG_Users _
Select
New
With {.Name = LG_User.UserName}).Single
End
Using
lblUserNameb.Text=
The query should only ever return one user so I know there will only be username.
Any assistance would be extremely appreacited, I'm a newcomer and can not figure it out.
View Replies !
Trouble with declaring Anonymous types?   (1 Views)


I'm struggling to find out how can i declare Anonymous types. I want to do a various query on the basis of a condition. Some thing like this:If true then
Dim Myquery = From data In MyXML.Root. _
Select New With { _
.SensorID = CType(data.(0) Integer)}
else
Dim Myquery = From data In MyXML.Root.. _
Select New With { _
.SensorID = CType(data.(0), Integer)}
end ifThen I need to reference MyQuery outside of the condition. But How can I declare MyQuery outside of the if statement
View Replies !
Reference to a nonshare member requires an Object references   (3 Views)


how is I was windering if u guys can assist me I was attempting to make a reference with a constant but of course I can not do that and before hand I receive this error message "Refrence to a nonshare member requires an Object references" But umm I know
I want to make an instance but I really am confused how for the construct. Here's my code snippet: THis is just the class
Public
Class Info
Private CarsDecimal
As
Decimal
Private AddonsDecimal
As
Decimal
Private TradesDecimal
As
Decimal
Private ST
As
Decimal'Naming the variables
Const STEREO_Decimal
As
Decimal = 425.76D
Private StereoDecimal
As
Decimal = 425.76D
Const LEATHER_Decimal
As
Decimal = 987.41D
Private LeatherDecimal
As
Decimal
Const COMPUTER_Decimal
As
Decimal = 1741.23D
Private ComputerDecimal
As
Decimal
Const STANDARD_Decimal
As
Decimal = 0D
Private StandardDecimal
As
Decimal
Const PEARLIZE_Decimal
As
Decimal = 345.72D
Private PearlizeDecimal
As
Decimal
Const Personalized_Decimal
As
Decimal = 599.99D
Private CustomDecimal
As
Decimal
Const TAX_RATE_Decimal
As
Decimal = 0.08D
Private Tax
As
Decimal
'Parameterized Constuctor
Sub
New(ByVal Cars
As
Decimal
ByVal Adds
As
Decimal, _
ByVal Trades
As
Decimal,
ByRef StereoDecimal
As
Decimal, _
ByRef LEATHER_Decimal
As
Decimal,
ByVal COMPUTER_Decimal
As
Decimal, _
ByVal STANDARD_Decimal
As
Decimal,
ByVal PEARLIZE_Decimal
As
Decimal,
ByVal Personalized_Decimal
As
Decimal)
'Assign property value
With
Me
.Cars = Cars
.Adds = Adds
.Trades = Trades
.Stereo = Stereo
.Leather = Leather
.Computer = Computer
.Standard = Standard
.Pearlize = Pearlize
.Custom = Custom
End
With
CalculateSubtotal()
CalculateTotal()
CalculateAmount()
End
Sub
Property Cars()
As
Decimal
Receive
Return CarsDecimal
End
Receive
Set(ByVal value
As
Decimal)
If value >= 0
Then
CarsDecimal = value
End
If
End
Set
End
Property
Property Adds()
As
Decimal
Receive
Return AddonsDecimal
End
Receive
Set(ByVal value
As
Decimal)
If value >= 0
Then
AddonsDecimal = value
End
If
End
Set
End
Property
Property Trades()
As
Decimal
Receive
Return TradesDecimal
End
Receive
Set(ByVal value
As
Decimal)
If value >= 0
Then
TradesDecimal = value
End
If
End
Set
End
Property
Property Subtotal()
As
Decimal
Receive
Return ST
End
Receive
Set(ByVal value
As
Decimal)
ST = value
End
Set
End
Property
Property Stereo()
As
Decimal
Receive
Return StereoDecimal
End
Receive
Set(ByVal value
As
Decimal)
If value >= 0
Then
StereoDecimal = value
End
If
End
Set
End
Property
Protected
Overridable
Sub CalculateSubtotal()
'Calulate the subtotal
ST = CarsDecimal + AddonsDecimal
If StereoBox.Checked
Then
AddonsDecimal += STEREO_Decimal
End
If
If LeatherBox.Checked
Then
AddonsDecimal += LEATHER_Decimal
End
If
If ComputerBox.Checked
Then
AddonsDecimal += COMPUTER_Decimal
End
If
If StandardRadioButton.Checked
Then
AddonsDecimal += STANDARD_Decimal
End
If
If PearlizeRadioButton.Checked
Then
AddonsDecimal += PEARLIZE_Decimal
End
If
If CustomRadioButton.Checked
Then
AddonsDecimal += Personalized_Decimal
End
If
End
Sub
End
Class
Sorry for the problem I just want to know what to do.
View Replies !
Obtain utf-8 html entity (decimal) from non-latin1 characters   (3 Views)


This has been a pain for me. I finally figured out what I needed to do. I want to convert special characters into their HTML entity counterpart but it is just not working as simple as I thought.
Vb's asc() function does not support unicode characters, that is sort of expected, and I can use chrW to show a non-latin1 character, but How can I encode that entity to even be put into the chrW function
Here's generally what I am attempting to do:
I have a site I am scripting in that I want to store Japanse characters into a db, but the db will only accept latin1 characters direcetly, now before u go ah ha on me, point out my entire db is already in UTF-8, I just can not store anything
into the db, so what I want to do is just convert these characters into an html entity.
Example: I want , the kanji for correct,to be stored in the db as:&# 27491;
ASC() in VB will return the entity for . Any clues And would this be cross-browser friendly I am only looking for IE6+, FF 1.0+, and the latest versions of the other browser types.
btw: I have no real code to display since I can'tfind the method to begin with.
View Replies !
Child forms and operation - non-MDI  (2 Views)
I've a project with a main form and a second form with a grid on it.
Neither form is an MDI thus neither form is a child - tare two
independent forms. The CALCULATE button on the main ...
View Replies !
Instrumenting non-.NET DLL w Version Info?  (12 Views)
-
I was thinking if there is a way to add version info to a DLL
that wasn't built with .NET. In .NET ( VB ) I've the AssemblyInfo. vb
file that contains to set ...
View Replies !
"non-reentrant method"?  (1 Views)
For some reason when I call validateFields before .Edit (see given below) I receive
this error message: "Consumer's even handler called a non-reentrant method in the
provider"
However if I comment out the call to validateFields, all is fine.
What could possibly ...
View Replies !
VB 6.0 and problme with controls with non-English language  (3 Views)
group
I've used Visual Introductory 6.0 to write a COM AddIn for Excel in English
however, now I want to make flexible for Japanese and English.
However, using the standards control causes difficulty since tdon't
support Japanese or ...
View Replies !
index was out of range. must be non negative and less than the size of the collection. Parameter name: INDEX   (12 Views)


Hello
I'm hoping somebody can assist me By this. I fairly newbie to vb.net.
What I am attempting to do is send vars to a flash file.
The following is my code snippet:
ProtectedSubPage_Load(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesMe.Load DimoTitleAsNewArrayList
DimoSubAsNewArrayList
DimoRateAsNewArrayList
DimstrFlashVarsAsString="" DimoDBSettingsAsGenLib.Objects.DatabaseSettings=Session("Db")
DimoDBAsNewGenLib.Data.SQL(oDBSettings)
DimoDRAsSqlDataReader
DimoParamAsSqlParameter
DimoParamsAsNewArrayList Try
Fori=1To3
oParam=NewSqlParameter("@int",i)
oParams.add(oParam) oDR=oDB.RunStoredProcedure("cms_GETRates",oParams,True) IfoDR.ReadThen
oTitle.add(i)
oSub.add(i)
oRate.add(i).ToString()
EndIf strFlashVars=strFlashVars+"t"+(i).ToString+"="+oTitle(i)+"s"+(i).ToString+"="+oSub(i)+"r"+(i).ToString+"="+oRate(i) Next CatchexAsException EndTry Response.Write(strFlashVars) 'Resetconnection.
oDB.CloseConnection()
oDB.ClearParameters()
oParams.Clear() EndSub
----------------------------------------------------------------------------------------------------
What I'm expecting the output to show is some thing like "t1=value&s1=value&r1=rate&t2=value&s2=value&r2=rat&t3=value&s3=value&r3=rat"
But... i keep getting this exception: index was out of range. must be non negative and less than the size of the collection. Parameter name: INDEX.
Can someone assist
View Replies !
Processo che non termina  (1 Views)
A qualcuno mai successo che alla chiusura del programma il processo
del programma non si chiuda e parta un'altro processo di windows
(cideamon.exe) che occupa il 100 della CPU
Il codice l'ho controllato e ricontrollato e dovrebbe essere ok ...
View Replies !
Reference to a non-shared member requires an Object reference   (9 Views)


I am getting the above error message now when I execute one of my ASPX pages written in VB.NET. So I tried following the solution at:
http: msdn.microsoft.com en-us library zwwhc0d0(v=vs.80).aspx
The above link seemed promising, cause it seemed to describe my difficulty exactly. And Here's my modified source code snippet causing this error, but based off of Mike Smith's solution:

Namespace
Globalfunctions
PublicClassGlobalF
PublicfunctionComplaintTrendingDrillDown3p(ByValFirstMonthAsDateTime,ByValLastMonthAsDateTime,ByValrowLevelAsInteger,ByValproductGroupAsString,ByValcategoryAsString,ByValListNumberAsString)AsDataSet
DimDSPageDataAsNewSystem.Data.DataSet
Dimparam(5)AsSqlclient.SqlParameter
param(0)=NewSqlParameter("@FirstMonthDate",SqlDbType.DateTime)
param(0).Value=FirstMonth
param(1)=NewSqlParameter("@LastMonthDate"
,SqlDbType.DateTime)
param(1).Value=LastMonth
param(2)=NewSqlParameter("@TheLevel",SqlDbType.Int)
param(2).Value=rowLevel
param(3)=NewSqlParameter("@ProductGroup",SqlDbType.Varchar)
param(3).Value=productGroup
param(4)=NewSqlParameter("@TheCategory",SqlDbType.Varchar)
param(4).Value=category
param(5)=NewSqlParameter("@ListNumber",SqlDbType.Varchar)
param(5).Value=ListNumber
''#AUsingblockwillensurethe.Dispose()methodiscalledforthesevariables,evenifanexceptionisthrown
''#ThisisIMPORTANT-notdisposingyourconnectionsproperlycanresultinanunrespsonsivedatabase
UsingconnAsNewSQLConnection(ConfigurationSettings.AppSettings("AMDMetricsDevConnectionString")),_
cmd
AsNewSQLCommand("ComplaintTrendingDrillDown3p",conn),_
daAsNewSQLDataAdapter(cmd)
cmd.CommandType=CommandType.StoredProcedure
cmd.Parameters.AddRange(param)
da.Fill(DSPageData)
EndUsing
ReturnDSPageData
Endfunction
EndClass
PublicClassCallingClass
PublicGlobalF2AsNewGlobalF
'PublicfunctionCallingClass(ByValFirstMonthAsDateTime,ByValLastMonthAsDateTime,ByValrowLevelAsInteger,ByValproductGroupAsString,ByValcategoryAsString,ByValListNumberAsString)
'Dimcc_newAsNewCallingClass()
'Endfunction
PublicfunctionComplaintTrendingDrillDown3p(ByValFirstMonthAsDateTime,ByValLastMonthAsDateTime,ByValrowLevelAsInteger,ByValproductGroupAsString,ByValcategoryAsString,ByValListNumberAsString)AsDataSet
DimDSPageDataAsNewSystem.Data.DataSet
Dimparam(5)AsSqlclient.SqlParameter
param(0)=NewSqlParameter("@FirstMonthDate",SqlDbType.DateTime)
param(0).Value=FirstMonth
param(1)=NewSqlParameter("@LastMonthDate",SqlDbType.DateTime)
param(1).Value=LastMonth
param(2)=NewSqlParameter("@TheLevel",SqlDbType.Int)
param(2).Value=rowLevel
param(3)=NewSqlParameter("@ProductGroup",SqlDbType.Varchar)
param(3).Value=productGroup
param(4)=NewSqlParameter("@TheCategory",SqlDbType.Varchar)
param(4).Value=category
param(5)=NewSqlParameter("@ListNumber",SqlDbType.Varchar)
param(5).Value=ListNumber
''#AUsingblockwillensurethe.Dispose()methodiscalledforthesevariables,evenifanexceptionisthrown
''#ThisisIMPORTANT-notdisposingyourconnectionsproperlycanresultinanunrespsonsivedatabase
UsingconnAsNewSQLConnection(ConfigurationSettings.AppSettings("AMDMetricsDevConnectionString"
)),_
cmdAsNewSQLCommand("ComplaintTrendingDrillDown3p"
,conn),_
daAsNewSQLDataAdapter(cmd)
cmd.CommandType=CommandType.StoredProcedure
cmd.Parameters.AddRange(param)
da.Fill(DSPageData)
EndUsing
Return
DSPageData
Endfunction
EndClass
EndNamespace
And from my main ASPX page calling this function:
Dim gf As New Globalfunctions.CallingClass
DSProductData = gf.GlobalF2.ComplaintTrendingDrillDown3p(FirstMonthDate, LastMonthDate, TheLevel, ProductGroup, TheCategory, ListNumber)
I think Mike Smith is correct about not using Shared, cause I think that caused this difficulty. However, I am a newcomer at VB.NET and I am uncertain how else to declare an instance as an Object variable and then reference this instance by variable name. Can you
assist
The error I receive for the above is:
System.ArgumentException: Column 'QXP_SHORT_DESC' does not belong to table Table
Where the offending line is in this same main ASPX file:
If pException("QXP_SHORT_DESC") = TheCategory Then
But I know this stored proc does have an output field named this.
View Replies !
show non-modal form from modal form  (5 Views)

I know that in VB it is not possible to display a non-modal form from a modal
form so I was thinking if anybody can provide me any alternatives.
My scenario is quite easy. the user is on a modal ...
View Replies !
Child forms and operation - non-MDI  (2 Views)
I've a project with a main form and a second form with a grid on it.
Neither form is an MDI thus neither form is a child - tare two
independent forms. The CALCULATE button on the main ...
View Replies !
Still visible nonvisible on next member ?  (2 Views)
Okay I've my code snippet set up like this:
Private Sub Check77_BeforeUpdate(Cancel As Integer)
If Me.Check77 = False Then
Me.Risks.Visible = False
Me.Risk1.Visible = False
Me.RiskText.Visible = False
Me.Risk1text.Visible = False
Me.RiskButton.Visible = False
ElseIf Me.Check77 = True Then
Me.Risks.Visible = True
Me.Risk1.Visible = True
Me.RiskText.Visible = True
Me.Risk1text.Visible = True
Me.RiskButton.Visible = True
End If
End Sub
Private Sub Check77_Click()
If Me.Check77 = False Then
Me.Risks.Visible = False
Me.Risk1.Visible = False
Me.RiskText.Visible = False
Me.Risk1text.Visible = False
Me.RiskButton.Visible = False
ElseIf Me.Check77 = True Then
Me.Risks.Visible = True
Me.Risk1.Visible = True
Me.RiskText.Visible = True
Me.Risk1text.Visible = True
Me.RiskButton.Visible = True
End If
End Sub
The difficulty I'm having is that if I select or de select my tick box even though the next record isn't selected the items are still visible on the next page.
I'd like it set up so that it only applies if that records tick box is or is not checked.
Sorry for all the questions I'm a little bit of a programming noob but ur assist is greatly appreciated.
View Replies !
Shell functionon Windows 7  (7 Views)
Difficulty:
Windows 7
Account Type: Limited
I'd like to know how i'd execute a software that is blocked by group policy to execute. I've tried
sub test()
Shell ("C: User Me Destop test.exe")
End
Now all i receive is access denied
I know there is a way of doing this becasue a mate from school has done it
View Replies !
non preemptive priority scheduling  (5 Views)
[font=Garamond][size=7]
hello pls assist me making my project..
programming non preemptive priority by VB..
please tell me how can i do this,. tnx in advance..
View Replies !