|
Hi,
if you don't provide an explicit seed a random number generator will use the current time
as a seed, so everytime you create a new Random (within the same millisecond or so) it
will generate the same sequence.
Solution: insert a Thread.Sleep(1000) and/or provide a variable seed somehow
[added] or avoid creating new Randoms all the time (just have a single static one and
keep using it) [/added].
-- modified at 20:36 Friday 2nd November, 2007
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks Luc Pattyn . I got it corrected. Thanks for your solution
|
|
|
|
|
I am building a cash register with one textbox showing the item, another the price and another the quantity of that item being purchased.
How can I get a line in a listbox to show the price, quantity and item purchased?
Also, with another list box just containing the totals of each item purchased, how can I get a grand total with 2 decimal places?
Thank you
|
|
|
|
|
1 - by adding an item to the listbo
2 - by using the overload of ToString that takes a format specifier.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Don't understand the response can you please give an example
Thanks
|
|
|
|
|
ListBox1.Items.Add(new ListBoxItem(theStringYouWantInTheListBox);
decimal theAmount = 3.345234;
string currency = theAmount.ToString("c");
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi, I need to inherit my Form2 to Form3, when i use 'Inherits Form2' my form3 doesnt show up and I get this error message and I cannot view my Form3 design at all!
<br />
Warning 1 The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: <br />
<br />
Form3 --- The base class 'WindowsApplication1.Form2' could not be loaded. Ensure the assembly has been referenced and that all projects have been built. 0 0 <br />
All i want to do is use some text out of a textbox in form2 and display it in a label on form3
Many thanks, Brad
|
|
|
|
|
Brad,
Try this:
vb.net 2003:
declare an instance of Form2 in Form3
Dim newForm2 As New Form2
label.text = newForm2.textbox.Text
vb.net 2005:
no need to declare an instance of Form2 in Form3
label.text = Form2.textbox.Text
Hope this helps.
Ken
|
|
|
|
|
Much love x
Thanks man! (y)
|
|
|
|
|
Hi All
I am working on a project at present i have half of it done already in VB.net server side but i require to use another language platform to code the client side to consume the XML and display the XML doc. Can anybody explain what i should be looking for to get started on this.
This is a crossplatform web service Client/Server with 2 different languages for instance i have done LoanCalcService in VB.Net server side and created with the use of XML doc and now just require to consume XML, SOAP, WSDL etc with another language platform client side and display. Please
Thank You Beforehand
|
|
|
|
|
I am having a problem with a few Crystal Reports that I can’t seem to track down. It is the same problem so I am sure that once I get one fixed then I can fix the same problem with the other. I am working with VB.Net 2005 and working with the CR (10.2.3600.0) version that ships with it.
My report looks at a single table in my Dataset. When I add or edit items in the program and then run the report they show up just fine. But when I delete an item and then run the report it still shows the item I deleted. I have to close out of my program and reopen then run the report before that item is removed.
I have verified that I am Updating and Filling the Dataset before I run the report. I tried creating a whole new report but it has the same problem. Can anyone help me with this?
|
|
|
|
|
I am new to web development, and to this point I have learned everything from help pages and forums like this. I have viewed many posts on submitting forms, but none seem to cover my problem. All I want to do is have users enter in information, and click submit so an email will be sent to me with their information. Nothing fancy. I tried following a suggestion using an email template and a "sendmail.asp" file. I kept getting this error:
----------
[HttpException (0x80004005): The HTTP verb POST used to access path '/Website/sendmail_cdo.asp' is not allowed.]
System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) +464
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +166
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +146
----------
Can someone please help me out. I am in over my head on this one.
Thank you.
-Christian
|
|
|
|
|
You can't use an asp page in an ASP.NET site. However, you can send an email from ASP.NET, quite trivially. Did you try google ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I need to send username,userid, and user email in an xml file. This xml file is wrapped in a cookie and what I need to do now is send this cookie using httpwebrequest to another website.
My code is as follows:
<br />
<br />
Dim webBrowser As HttpWebRequest<br />
Dim sXmlData As XmlDocument<br />
Dim sCookie As HttpCookie<br />
<br />
sXmlData = New XmlDocument()<br />
<br />
'writing data to an xml document<br />
With sXmlData<br />
.LoadXml(("<Xml><username>" + Me.UserInfo.Username + "</username><uid>" + Convert.ToString(Me.UserId) + "</uid><email>" + Me.UserInfo.Email + "</email></Xml>"))<br />
.Save("D:\\std.xml")<br />
End With<br />
<br />
<br />
'reading the xmldocument into a cookie<br />
sCookie = New HttpCookie("UserInfoCookie")<br />
With sCookie<br />
.Values.Add("UserInfoCookie", sXmlData.InnerXml)<br />
End With<br />
<br />
'sending the cookie using response but I want it through httpwebrequest<br />
' Response.Cookies.Add(sCookie)<br />
' Response.Redirect("http://www.abc.com")<br />
<br />
<br />
Try<br />
webBrowser = HttpWebRequest.Create("http://www.abc.com")<br />
<br />
With webBrowser <br />
.CookieContainer.Add(sCookie) 'this line is giving me an error<br />
End With<br />
<br />
Catch ex As Exception<br />
<br />
End Try<br />
<br />
<br />
thank you
|
|
|
|
|
OK, I love to learn new and better ways to do things, but this just doesn't seem one of them.
I'm originally from the Java camp so I've used straight DB code such as hard coded calls to the database and ORM tools like Hibernate. I've been working in VB for the past 5 years on various projects and have used similar techniques here as well.
I am working on a fairly large project and decided to use strongly typed db access such as what is taught in these fairly popular tutorials:
http://www.asp.net/learn/data-access/[^]
Boy am I getting a headache. It seems to me that the only benefits I get are IntelliSense and compile time checking. IntelliSense wasn't available before strongly typed database code so this is more of a convenience than any real need. Compile time checking is nice but I've already had several errors that are not caught until runtime. These errors largely deal with enforcing constraints when filling a DataTable using a standard DataAdapter. Most of these errors are extremely trivial, do not interfere with my actual code and would never have been brought to my attention without strongly typed db code.
So here is what I see as the major negative. I feel like I am getting much more code dependence rather than the current shift towards independence. This project largely works with data from a vendor database. If they ever update their schema (which can be as often as once a week) my app will break, even if they simply change a field from varchar(10) to varchar(12).
I'm starting to lean towards either rolling my own db code or using NHibernate again. Also, LINQ seems to be a departure from this strategy as well.
Does anyone else have any comments? Have any of you used strongly typed db code on a large project and found it to be indispensable? What am I missing?
Thanks!
Matt Penner
-- modified at 17:13 Tuesday 6th November, 2007
|
|
|
|
|
Hi to all,
I'm writing a code (in VB .net Compact Framework environment) to read a text file (where is included a field containing a DateTime in Ole Automation format i.e.: 39097.4010995 is equivalent to 1/15/07 9:37:34 AM ).
Before to adding the part of code relative to above work,the program (in fase of development yet), was working almost perfectly in both emulator (windows mobile 2003 SE) and the real device.
After I added the following code lines (only that relatives to DateTime elaboration):
----------------------------------------------------
Dim Tempi() As Single
Dim DatOra As DateTime
Dim Tempo As TimeSpan
Dim Tempo1 As DateTime
Dim Tempo2 As DateTime
Tempi = New Single(TotRecords) {}
DatOra = DateTime.FromOADate(Microsoft.VisualBasic.Mid(line, D1, D2))
If CountLines = 7 Then
Tempo1 = DatOra : Tempo2 = DatOra
Else
Tempo1 = Tempo2 : Tempo2 = DatOra
Tempo = Tempo2 - Tempo1
End If
Tempi(CountLines - 7) = Tempo.TotalSeconds
-------------------------------------------------------
the program is perfectly working only on emulator, but on real device, return me this error:
ArgumentException
Impossible to show an error message. It is not been found assembly of the optional resource that contain it.
in System.DateTime.DoubleDateToTicks()
in System.Windows.Forms.Form.WnProc()
in System.Windows.Forms.Control._InternalWnProc()
in Microsoft.AGL.Forms.EVL.EnterMainLoop()
My device is Windows mobile 2003 SE based, updated to Version 2.00 of Compact framework, and is Italian language Culture.
To develop code, I'm using English version of VS 2005 and Compact Framework environment.
Any idea on where is the problem?
May be that problem depends on different languages (I am not sure)? If yes can someone help me please?
Marco
|
|
|
|
|
After 2 days I resolved problem simply correcting the line:
DatOra = DateTime.FromOADate(Microsoft.VisualBasic.Mid(line, D1, D2))
with:
DatOra = DateTime.FromOADate(Val(Microsoft.VisualBasic.Mid(line, D1, D2)))
But remain a mystere why in the emulator the code works!
Marco
|
|
|
|
|
I've been trying to apply xp visual style on my forms. I saw some examples on creating custom buttons and other controls but i didn't get any help on making an inherited custom form, i tried on my own but to no avail. Pls i need help.
Julius Momnang
|
|
|
|
|
Hi..
I am not very clear about what exactly you mean but let me give it a shot
What is the language u are using and what is the IDE ...
If you are using VB.Net & microsoft IDE then there is a setting in project properties telling "Enable XP visual style"
may be that will help you
|
|
|
|
|
Hello!
I am using a Pen:
dim myPen as pen
myPen = new pen(Color.Black,1)
if i use 'myPen' to draw a rectangle/Line and then print that rectangle/Line it is of thickness '1'. Which seems quite thick when printed.
How can i print a line/BOX with line thickness '0.25' OR '0.50' instead of '1'.
Thank you
-- modified at 9:10 Friday 2nd November, 2007
colgateas900197
|
|
|
|
|
Did you try this?
dim myPen as pen
myPen = new pen(Color.Black,0.25)
Ken
|
|
|
|
|
yes! i do.
what ever you write less than 1 it draws line of width 1 by default.
colgateas900197
|
|
|
|
|
Do you generate a bitmap at screen resolution and print that?
or do you call OnPaint() to generate the printed page with appropriate PaintEventArgs?
in the first case, your 1-screen-pixel-thick line will be rescaled to the printer's
resolution, resulting in thick lines and rough fonts.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi there,
I am newbie to Crystal Report in .NET 2005. I am trying to connect my report with both SQL as well Oracle Database based on the Report Type. If the Report type is SQL, I am taking the DSN Name as input, which inturn get the Server's name from the Registry, else "Oracle" the Server Information is taken from the TNSNAMES.ORA file.
The SQL connection works fine. But when I try to connect to Oracle, I am getting the Error message as,
"Database logon failed."
Stack Trace is
Database logon failed.
Exception occured at:
at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToDisk(ExportFormatType formatType, String fileName)
at TestDBconnection.vbproj.PaceReportsFactory.Execute(IPaceReportInfo reportInfo) in F:\PROJECTS\PaceLite\Toolkit 9.0\Crystal Report\TestDBconnection\pacereportsfactory.vb:line 65
at AdvReportTestUtility.frmAdvTest.RunReport(String& report_path, String& report_type)
PaceReportsFactory & AdvReportTestUtility are some internal utility used in our company for testing reports.
Thanks in advance.
|
|
|
|
|
Hi in my dataset i have like this records:
UID ID MNa PID PName URL
100 1 Admin 102 Page page1.aspx
100 1 Admin 103 User page2.aspx
100 2 Gen.M 137 Mate page8.aspx
100 2 Gen.M 106 Proj page6.aspx
Now I stored this dataset in my datatable:
Dim Dt as datatable=ds.tables(0)
Now I have to Add this datatable MNa Field in my arraylist...,
But the repeated name wont ocur...,
Means i have To Bind only:
Admin
Gen.M
Plz Help me...,
Regards,
Magi
|
|
|
|