|
The "Hamster" namespace, obviously, isn't part of the .NET Framework. It's something the author of the article wrote and should be included in the downloads attached to the article.
It looks like this this is doing a bunch of custom drawing, but without the missing pieces, it's impossible to say what's wrong. Your best source of information on this code would be the person who write the article. The bottom of every article has a discussion board. Post your question there.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi, I am trying to work out how to write some code that will generate a selection of 6 numbers which are random but each number be unique, I know that you can add the RANDOMIZE to the form load which I have done and this will produce a random selection of numbers but the numbers are not always unique i.e. a number may appear twice and this is where I am getting stuck.
Help!!!;)
|
|
|
|
|
The simplest (and least efficient) way to do this would be to generate the numbers, compare them all and if you get any duplicates, generate a new number for one of the duplicates and check again.
Regards,
Tristan Jones
|
|
|
|
|
Hi Tristan,
Thanks, I don't suppose you can give me a clue with where to start with the coding (yes I am completing new at this)
This is a sample of the coding I have to gentrate the numbers and the Randomize:
Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
lblLottoBall1.Text = CStr(Int(Rnd() * 49)) + 1
lblLottoBall2.Text = CStr(Int(Rnd() * 49)) + 1
lblLottoBall3.Text = CStr(Int(Rnd() * 49)) + 1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize
|
|
|
|
|
Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
lblLottoBall1.Text = CStr(Int(Rnd() * 49)) + 1
Do Until (lblLottoBall2.Text <> lblLottoBall1.Text)
lblLottoBall2.Text = CStr(Int(Rnd() * 49)) + 1
Loop
Do Until (lblLottoBall3.Text <> lblLottoBall1.Text And lblLottoBall3.Text <> lblLottoBall2.Text)
lblLottoBall3.Text = CStr(Int(Rnd() * 49)) + 1
Loop
End Sub
Like i said this is a bit inefficient, but on the other hand it looks like you're writing a windows app so timing shouldn't be a huge issue. Plus most of the time it won't have to regenerate a number anyway (only one time in 25 i think?) so you're gonna have very little overhead anyway, mainly just from the comparisons.
Regards,
Tristan Jones
|
|
|
|
|
Here is a neat way of doing it:
www.guffa.com : Random without duplicates[^]
The code is in VBScript, but you should easily be able to convert it. The code itself is not complicated, actually it's surprisingly simple. It's the theory behind the algorithm that is clever.
---
b { font-weight: normal; }
|
|
|
|
|
hi everybody, plz if any one could help me in this pb
i need to add a scrollbar to my form & i want to activate them, i mean that i want when i press on the horizontal scrollbar, my form start to move.
can anyone help me plz on this
i be very thankfull.
waelhawari
|
|
|
|
|
Well, it's possible, but a bit of a pain to handle, depending on what you're doing with them.
If all you're doing is putting a bunch of controls on the form and trying to move them around because the form is too small to show them, you're really wasting your time. All you need to do is drop a Panel control on the form, dock it so it takes up the entire surface of the form, set its AutoScroll property to True, then put all your controls on the panel. It takes care of moving everything around for you!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi again
In fact, yes i need to put a lot of listbox control & the form is to small, so is there is anyway to do that.
i need help on this plz, it's so urgent.
10x a lot for replyin.
waelhawari
|
|
|
|
|
Hi again
In fact, yes i need to put a lot of listbox control & the form is to small, so is there is anyway to do that, i am using a visual basic 6 platform.
i need help on this plz, it's so urgent.
10x a lot for replyin.
waelhawari
|
|
|
|
|
VB6?? Yikes...
The only other usable container control, IIRC, is the PictureBox. There is no Panel control like there is in .NET.
If you have that many controls on the form, you REALLY need to rethink your UI. Break down what each part of this form does into smaller parts and dedicate them to their own forms.
I direct you to the Official Guidelines for User Interface Developers and Designers[^]. This describes the concepts behind a good user experience.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Any way, it's ok 10x a lot for replyin..
i will use i pictureBox & i will put the Scrollbar on it.
10x a lot again
waelhawari
|
|
|
|
|
Hi all,
I'm currently trying to add (with a button) rows into tables (html table, asp table or gridView) .
I've tried : (asp:Table)
Private Sub AddRow()
Dim count As Integer = procTable.Rows.Count //never increment !!!
Dim myRow As New TableRow
Dim myCell As New TableCell
myCell.Text = "myCell"
myRow.Cells.Add(myCell)
'this is the asp:Table
procTable.Rows.AddAt(count, myRow)
End Sub
Had anyone an idea???
Thanks a lot
ElpenS
-- modified at 10:26 Tuesday 4th July, 2006
|
|
|
|
|
hi Everybody
I am working in vb i created a dll which i call from the visio add in .its working fine for one document.but when I call it from two document it is not working properly,its works for the document which calls it later if someone have idea Please help me, its really urgent.
Thanks
|
|
|
|
|
hi. i'm new in the VB language... can you help me on how to connect to an access database? Can you show me some codes on how to do it? thanks
|
|
|
|
|
|
|
Connect to MS Access
Dim Conn as OleDbConnection
DIm strConn as String
strConn="Provider=Microsoft.Jet.OleDB.4.0; data source=C:/Northwind.mdb"
Conn = New OledbConnection(strConn)
Conn.Open()
Hope can help you
................
|
|
|
|
|
Socheat.Net wrote: strConn="Provider=Microsoft.Jet.OleDB.4.0; data source=C:/Northwind.mdb"
Becareful about an example path:
C:\Northwind.mdb
|
|
|
|
|
Hi
Has anyone worked with DVT cameras? I want read and write camera registers. With activeX I can control the camera fine but working with camera registers(string,byte,int,...) acticeX is not capable (I think so). I use VB.Net 2003 standard version.
|
|
|
|
|
I am using a function to keep an error log in case of run-time errors. When the program breaks, ex.stacktrack and ex.innerexception, containing useful technical information are not written to the log file.
Any ideas?
Jon
:->
Code:
Friend Sub DisplayError(ByVal Caption As String, ByVal ErrorMessage As String, _
ByVal LogError As Boolean, Optional ByVal InnerException As String = " ", _
Optional ByVal StackTrace As String = " ")
' Displays an error message and logs the error
If Caption = "" Then
MessageBox.Show(ErrorMessage, Caption, MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
MessageBox.Show(ErrorMessage, Caption, MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If LogError = True Then
'Log the error message in a text file
Dim ErrorLog As New StreamWriter(strAppPath & "\" & "Error.log", True)
Const strDelimiter As String = ","
Try
ErrorLog.Write(Now.ToString)
ErrorLog.WriteLine(strDelimiter & Caption & _
strDelimiter & ErrorMessage & _
strDelimiter & InnerException)
Finally
ErrorLog.Close()
End Try
End If
End Sub
Jon
|
|
|
|
|
Do you send any inner exception string to the method?
You have no code that writes the stack trace to the file.
---
b { font-weight: normal; }
|
|
|
|
|
|
i need to implement Cut and paste in VB.NET Application.
I m finding Error-->strType = CType(sender, MenuItem).Text.
Kindly reply a working solution for this.
Thanks.
pooja
|
|
|
|
|
Standard question #2:
What error message do you get?
---
b { font-weight: normal; }
|
|
|
|