Using Random In Winforms?

Jan 14, 2012

I'm creating a playlist in Visual Studio 2010 Winforms and I would like to have allow the user to shuffle the songs played. I was thinking of something like:

If CheckBox1.Checked = True Then //Shuffle checkbox
Me.ListBox2.SelectedIndex = Random(20)
AxWindowsMediaPlayer.URL = ListBox2.SelectedItem
End If

And hopefully the 1 of the 20 songs in the ListBox2 will be randomly selected. But this code does not work; "Random is a type and cannot be use as an expression".

View 1 Replies


ADVERTISEMENT

Creating A New Random Generator Each Time Should Reduce The Number Of Random Repetitions?

May 26, 2011

I've read numerous posts and threads about random number generation, but I havent' run across this.If I generate a bunch of random numbers, the results are radically different if I create a new Random generator for each number than if I use on Random generator for all the numbers. The results are much more consistent and evenly distributed if I use the same Random generator.I would have thought the opposite,because creating a new Random generator each time should reduce the number of random repetitions, if a different time slice is used to create the random number.[code]......

View 9 Replies

Bug In VB 2010 RC - Class Random - Always Produces The Same Random Numbers In The Same Sequence

Apr 4, 2010

The class Random is out right defective. It always produces the same random numbers in the same sequence. Things I have tried so far is every kind of seed you can think of as well as Randomize. The result is that I always get the same random numbers in exactly the same sequence.

View 4 Replies

VS 2010 Draw Rectangle (random Times, Random Location)?

Nov 26, 2011

I am practicing using the drawing commands, and have gotten a grass background and black happy face that moves around the background.It's a 10x10 grid of 50 pixels.I want (at the moment, when i press enter) it to generate a random number of trees (15 ~ 25) at random locations on the background. The program doesn't freak out about anything, and the variables seem to be right (using stop commands) but it's not drawing anything. Here is the code for the "GenerateTrees" command I have for when I press enter.

Private Sub GenerateTrees()
NumberOfTrees = Int(Rnd() * 10) + 15
For i = 0 To NumberOfTrees - 1
bmap.MakeTransparent(Color.Fuchsia)

[code].....

View 4 Replies

IDE :: Set Project Default For Winforms Projects S/ Default Modifier For Controls Added To Winforms Is Private

May 28, 2010

Is it possible to set a project default for VB.NET winforms projects so that the default Modifier for controls added to winforms is Private (not Friend)?I know there's a "modifiers" property in the properties window so I can set it for each individual control however I would like to change the project so from now on myself and other developers have to specifically decide to change from friend to private. (Which I would strongly discourage them from doing).I believe there is no way of doing this, but on another forum a while ago someone mentioned it would be possible with an add-in (but didn't name the add-in or where to get it).

View 1 Replies

Assigning Integers Using Random.org Instead Of The Local Random Feature?

Oct 10, 2011

I would like to use integers generated by Random.org in a small desktop widow app. Im using visual basic. All My search terms bring up unrelated (to My issue) information. Currently I am using the local random statement/command.

View 4 Replies

Code Generate A Random Number / How To Make It 'TRULY' Random

May 29, 2011

I am trying to make a texas hold em game and it is of the utmost importance that my code generate a random number. But using a random number function that I always end up with a lot of the same numbers over and over again. Any ideas on how to make it "TRULY" random? [code]

View 3 Replies

VS 2010 - Image Viewer - Random Number Is Not That Random At All

Apr 19, 2012

I've made an image viewer which opens a random image from a specified folder, but the random number is not that random at all... I've already used Randomize(), but without result.

View 3 Replies

Random Numbers And Random Strings

Nov 24, 2009

I don't take programming lessons at school or anything, and I'm starting to (try to) teach myself about random things.Currently I'm making an app that has 3 functions:

-Random Integer (1 to 100)
-Random Answer (Yes or No, similar to a coin flip)
-Random Dice Roll (1 to 6)

How would I go about doing this?At the moment all I know about random numbers etc. is that I will need to do something along the lines of Dim dice As New Random or something like that, but, like I mentioned, I have no idea.I am well aware of the DIC rules that you won't write the code for me/do my "homework(?)" for me, and that's not what I'm asking.

View 2 Replies

Generating Salt - LENGTH Of Salt Be Random - Fixed Or A Random Number Within A (min/max) Range ?

Nov 26, 2011

VS2010 (SP1) / .NET 4 on Windows XP. The question is simple, the answer; not so much. When generating a salt, should the LENGTH of the salt be random, fixed or a random number within a (min/max) range? I am using RNGCryptoServiceProvider to generate the salt, just unsure of the length of the salt.

View 12 Replies

Random Function Isn't Random?

Nov 25, 2009

I got a loop like this:

For KeywordsLoop = 1 To 150
TextFile1.WriteLine(RandomSuffix())
Next

[code].....

View 4 Replies

ASP.NET Vs Winforms App ?

May 11, 2009

I have a proto-type winform app designed by a colleague. My original plan was to create it using asp.net, but I'm not sure if I should just 're-create' it using asp.net or continue forward using the winforms. Either way, I'd use vb.net as the code-behind.

It's going to be a data collection app; originally it was going to allow the collection screens to by dynamically built, based on options selected by the end-users. However, that has changed to a one-size fits all approach.

I've never written anything using asp.net, so what I'd really like is some advice about what should I be looking for/at in this new app, in order to decide which way to finish it... asp.net OR winforms... Would there be any design/programming advantages to using asp.net over the winforms (other than the fact that my colleague already have about a dozen forms designed, but with NO code-behind)? Might there be end-user advantages to using asp.net vs winforms?

View 3 Replies

WPF App Vs WinForms App

Aug 10, 2009

I'm currently studying for one of Microsoft's MCPD 3.5 certifications (VB 2008) and one of the things it makes use of is WPF applications. Based on what I've seen of them so far, they are basically like Windows Forms Applications. So my question about them is why was WPF created? What was Microsoft looking to accomplish with WPF since outside of the "web feel" in a windows environment, it basically looks like a WinForms application. What is the difference between the two and when sould I use one over the other?

View 1 Replies

Access ASP.NET From Winforms?

Jul 24, 2011

Can i access ASP.NET Database From Withing Winforms Application ? If i expect it requires web server can i have any example, any online sites that can show me the pattern of simple web server?

View 1 Replies

Animated GIF In Winforms?

May 28, 2011

Animated GIF in Winforms

View 9 Replies

C# - Controlling Cmd.exe From Winforms

Nov 5, 2010

Question: I want to control cmd.exe from winforms. I DO NOT mean every command in a single process, with startupinfo, and then stop. I mean for example start the (My) SQL or GDB command prompt, send command, receive answer, send next command, receive next answer, stop SQL command prompt exit process. Basically I want to write a GUI on top of any console application.

[Code]...

View 4 Replies

C# - WindowLicker For .NET's WinForms?

Jul 22, 2010

Is there anything like WindowLicker(a GUI test framework) but for .NET's WinForms?

View 3 Replies

CSS Be Used In A WinForms Application?

Mar 9, 2010

Can we use css formatting in a vb application to give some enhancement? Examples would be changing the font color and or background? Are there any other way to customize a (VB)desktop application?

View 4 Replies

Migrating From WinForms To WPF

Jun 25, 2010

We're building an application using VB.net and WPF. Obviously we've found that there are huge differences between the syntax in the two, and we have a few problems trying to do things in Form apps in WPF.If possible, could you pass us some resources on things like switching between WPF windows, we'd use Show() and Close() in WinForms, and referencing variables from other forms, i.e. otherForm.StrVariable references StrVariable from otherForm.

View 2 Replies

VS 2008 Using WinForms And Asp.NET Together?

Mar 7, 2012

I've come up against a rather tricky problem that I cant seem to find an answer to.I have a WinForms program that runs locally on a PC with a SQL Server Express database to store its data.There is also a remote database that i need to save data to the first time that the program is run (a registration type thing).

The remote database will only accept connections from known IP adresses so to get around this, I have set up an ASP.NET site on the server that the remote database resides on and the data will be saved from here.

In my program, I have a form that has a webbrowser component on it that points to the asp site (with me so far?).The user fills in the form and clicks a button on the form that will fire the form to submit, save the data on the remote DB and retrieve a serial number that is displayed on the screen.

[Code]...

View 1 Replies

Way To Customize WinForms

May 7, 2009

I would like to change just a little bit the outlook of the form's top region in my application (the icon, bar, and controbox), is there any way to accomplish this without using third party components ?, I'd like to have my own Winform control that inherits from Windows.Forms.Form.[url]...

View 6 Replies

Porting Winforms Application To C#?

Jun 24, 2012

Possible Duplicate: Porting VB.NET Winforms Application to C# .Is there any way to convert a vb.net winforms application into c# ? In terms of both code and .vb (forms) files.

View 2 Replies

.net - Set CurrentPrincipal In Winforms For All Threads?

Jan 4, 2011

In a .NET 3.5 Winforms app, after a user provides a username and password, I set a custom principal in the CurrentPrincipal property like this:My.User.CurrentPrincipal = Service.GetPrincipal(username)This is done in a method that is called using Invoke, because the originating thread is not the UI thread:Invoke(New Action(AddressOf doLogin))But when I click on a button in the Winforms application, the CurrentPrincipal property has been reverted to its default, the current Windows user.Dim lPrincipal = My.User.CurrentPrincipal ' not my custom principalApparently, using Invoke while setting the principal does not solve the problem. Is there another way to set the CurrentPrincipal property for all threads in the application?

View 1 Replies

.net - Winforms Menu As Array?

Jun 20, 2009

I know it most likely possible to access a winforms menu like an array but I am not seeing it in the menu designer of VS2008? What I mean is, my app has a typical menu bar across the top, with multiple items on each drop down. As it is written (I inherited this code), each menu item is a separate name, i.e.

myMenuOption1MenuItem
myMenuOption2MenuItem
myMenuOption3MenuItem
myMenuOption4MenuItem

[Code]...

Obviously I could set/unset each menu item by name, but for a lot of reasons I'd prefer to use loops.

View 3 Replies

.net 2.0 - .net Winforms Design / Layout?

Dec 2, 2010

I am working on a windows forms project that will allow a user to have an interface to the database, and another will be a nightly run process file that will update the database table.The user will add new records to the table, whereas the nightly process will update the columns with new values (think mortgage interest rates)

Both these projects will be using the same business logic component that has the calculations needed to enter values into the table.The way I am figuring this out, is that I will have two exe's (one for the interface and one for the nightly process) and have a central object that will host the calculations. What would be the best object for this purpose?A class file?A windows service? (I want to stay away from a windows service, because it will have to be running all the time)

View 2 Replies

Binding And Threads In WinForms?

Oct 27, 2010

In my Winforms application, i've got a form and an associated business layer class. All controls are bound. When i click a button i call a method on the class which then starts a background worker and returns. The background worker does some processing and finishes.

The problem i'm having is that i'm using a label to display any error messages generated by this background worker, which is fine but after a set time i want to clear the label, so for that i'm using a timer (on the business layer class), which, when it fires, is on a different thread and thus should not update the property that the label is bound to Whats the best way to do update the label? -- Should i be using a delegate to update the property value, if so how do i invoke it?Note i'm also having a problem with getting the databinding of the visible property on this label to work.

View 5 Replies

C# - Adding WinForms ListViewGroup In WPF

Jan 9, 2012

Check this:Can I add ListViewGroup in WPF? Or a equivalent to that?

View 3 Replies

C# - WinForms Interthread Modification?

Jul 10, 2009

Whenever I want to modify a winform from another thread, I need to use ->Invoke(delegate, params)so that the modification occurs in the winform's own thread.
For every function that needs to modify the gui, I need another delegate function.Is there some scheme which allows me to limit the number of delegate functions needed? I have a controller class which handles the whole gui in one spot, I've thought about reusing delegates but that smells badly.I think that my question can apply to all languages where winform can run

View 4 Replies

C# - WinForms TrackBar Control In .Net?

Apr 7, 2010

know the millisecond interval, used by the framework trackbar, between calling the ValueChanged event when moving the grip with a mouse?I've implemented my own trackbar and I'd like the behaviour to be consistent with what the user expects.I've had a look in reflector but it's one of those controls where most of the implementation is not viewable.

ETA: Actually, thinking about it, it's not as simple as that. For small changes, the TrackBar is raising the event for every change. However, if you make a large fast change with the grip, it will not raise the event for every step. Just wondering exactly how the framework does this?

View 1 Replies

C# :: Hosting IE 8 In WinForms And Opening A PDF?

Apr 30, 2009

We have a form that hosts the WebBrowser control. That is the only control on the form.We pass the form the file path of a temporary PDF file and it does:WebBrowser1.Navigate(Me._PathToPdf)When the form is closing, it navigates away from the PDF file:

WebBrowser1.Hide()
WebBrowser1.Navigate("about:blank")
Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete

[code].....

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved