|
What I am trying to do is make a card game but in the hand there is not always a set amount of cards I am using labels for this I got it to create the labels as needed but what I am trying to do now is get it to where if the click on the card it moves up a little to signify that it has been selected but I can't figure that part out on how to do it. Here is an ex. of the code I am using to create the first part of the hand.
For N = 1 To 13
Label(N) = New Label
Label(N).BorderStyle = BorderStyle.Fixed3D
Label(N).BackColor = Color.Maroon
'PlayersHand is an Array with all the Card Numbers in them.
Label(N).Text = Player1Hand(N)
Label(N).Size = New Size(Label1.Width, Label1.Height)
Label(N).Font = Label1.Font
Label(N).TextAlign = ContentAlignment.MiddleCenter
CardX = CardX + 50
Label(N).Left = CardX
Label(N).Top = CardY
Label(N).BringToFront()
Me.Controls.Add(Label(N))
Next
If anyone can help me I would really appreciate it. Thank You for looking!
|
|
|
|
|
Your approach is fundamentally broken. You should do this by creating graphics which you store as resources and draw to the screen ( or at least draw text right where you want it ). Moving labels and pictures boxes around is just a disaster.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
In your FOR loop that is creating the labels, add an event handling function for the mouse click event, for example:
AddHandler Label(N).MouseClick, AddressOf CardClickFct
You will then need to create the CardClickFct, such as:
Sub CardClickFct(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) <br />
Dim TheCard as label = DirectCast(sender, Label)<br />
<br />
' TODO: Add whatever you want the card to do when its been clicked<br />
End Sub
What you must also remember to do is remove the event handler when the label is destroyed (by calling RemoveHandler)....
You MUST ensure that your array variable "Label" is declared "WithEvents" for this to work!!!
I hope this helps you out....
Regards,
Martin
|
|
|
|
|
|
try findstring on the text_changed event. Not Sure Exactly where to find it. maybe me.combobox1.findstring(me.combobox1.text), think that should do it. Should choose the closets matching item.
Posted by The ANZAC
|
|
|
|
|
i want to add a new column to an excel-table, the name of this new column is the caption of a datagrid's column.
the only problem: the column's caption consists of two words (firstname, surname).
i use this command:
<br />
Cmd1.CommandText="ALTER TABLE MyTable ADD '" & dt.columns(column).caption.tostring & "' FLOAT"<br />
this works fine, but the names are enclosed by '-characters which doesn't look too nice. without '-character it doesn't work anymore, of course.
any help?
|
|
|
|
|
I haven't understand the web service please help with some good example as soon as possible.
Arindam
|
|
|
|
|
I am working on a VB project.
I was successful in creating an executable for the client using 'File->Make Project.exe'. But I want to provide the client with a setup, so that the client can install the whole project.
Actually the client has provided me with some install scripts in the '.wse' format. I cant figure out how to create an installable using these files.
Has anyone used .wse files to create installables. Please help
|
|
|
|
|
Try a standalone installer.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
anyone knows on how to search specific text on a text file and able to modify it..
|
|
|
|
|
Load the file into a String variable, call Replace on it with the text you want to find and what to replace it with, then write the string back out to the file.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
U can do with many methods.
1st... U can read file with filestream and read as byte or readline and search string with "InStr" function. or looping.
2nd the best idea is "regular expression".
|
|
|
|
|
does anyone know how to list all the computers found on my network in a drop down list box?
I am working on this project that i need the user to select a computer name from a list of computer found on the network so as to setup up the system..
how do i list all the computer on my network..
Nab
|
|
|
|
|
Well, it depends on how your network is setup. Unless you're using Active Directory or the old NT Domains, there is no central database that lists all the machines on the network. You'll have to ping each and every IP address in your net to see if there is a response. But, that does NOT mean it's a Windows machine. It can be something else, like a network Printer, some server, Linux box, ... Even a non-response doesn't mean that a machine is not there. It could just be turned off.
Even using Active Directory or NT Domain, there's no guarantee that every machine on the network is a member of the domain.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Yes i am using Active Directory and all the computers are on the same domain..so now how do i go about listing them from that database...
Nab
|
|
|
|
|
|
Hi there,
I'm trying to build a simple application at work and im having a few problems. I'm not a programmer and am learning as i go though.
My problem is regarding the OpenFileDialog in the application. When clicking "open", the file dialog box will open for me. But when i click tyhe file and then open, nothing happens. I am probably going about this the wrong way.
All i need is a function so that the user can open the file they click. I do not want the file to be opened in my application but in the file type application (.vsd and .pdf).
I would greatly appreciate any help on this matter as the project is due pretty soon.
Thanks for taking the time to read this
Regards
Peter
|
|
|
|
|
I am not sure about vs2003 but in vs2005 it is System.Diagnostics.process.start(filename) and this will start the file in it's application.
Hope it helps.
|
|
|
|
|
Thanks very much for that. It works perfectly in 2003. Thanks again, really appreciate it.
Happy new year
|
|
|
|
|
Hi, I'm using VB.net 2003. I'm making a tcp/ip server/client program using "UNOLibs Class". I would like to know what is the best way to create/get a unique program ID so the server can identify witch client it's talking to. I would like an ID in case the two clients are from the same IP.
I can use a random number generator at startup, but would it be the best way?
Thanks,
Rob
|
|
|
|
|
|
Thank you very much!!
That's exactly what I was looking for. I had it working with a random number generator, but I think this will work better. Thanks again.
The fun part of programming is going to bed every night a more intelligent person.
Rob
|
|
|
|
|
Hello ...
I use .net by disconnected mode with Access database .
I want to make reports by the disconnected mode with Crystal report
But I realy failed . I want any one try to help me by any Example .
thanks for all
soly
|
|
|
|
|
|
i have make a program which enables you to draw on screen (on a form) using the mouse in any color and any size. It is really good and really useful, then one day when i fiddling with it i realized i could set timers to change the colors of the pen color to make it look 3-d, but when i ran it and compiled it, i was testing it, and it had errors like not changing the pen color, can someone help, here is my code:
if you find an answer or you need or would like either programs, just emai me on;
david-gee@hotmail.com
Option Explicit<br />
<br />
Private PointX() As Single<br />
Private PointY() As Single<br />
Private NumPoints As Integer<br />
Public c, j, c1, c2<br />
Private Drawing As Boolean<br />
<br />
<pre>
Private Sub Form_Activate()
c1 = vbBlack
c2 = vbBlack
c = 1
End Sub
</pre><br />
Private Sub Form_KeyPress(KeyAscii As Integer)<br />
Timer3.Interval = 1<br />
Timer4.Interval = 1<br />
If KeyAscii = 97 Then<br />
frmAbout.Visible = True<br />
frmAbout.Timer1.Interval = 500<br />
End If<br />
If KeyAscii = 49 Then<br />
Form1.cdbDialog.ShowColor<br />
c1 = Form1.cdbDialog.Color<br />
Form1.Enabled = True<br />
Form1.Visible = True<br />
Form1.WindowState = 2<br />
End If<br />
If KeyAscii = 50 Then<br />
Form1.CommonDialog1.ShowColor<br />
c2 = Form1.CommonDialog1.Color<br />
Form1.Enabled = True<br />
Form1.Visible = True<br />
Form1.WindowState = 2<br />
End If<br />
If KeyAscii = 32 Then<br />
NumPoints = 0<br />
Cls<br />
End If<br />
If KeyAscii = 43 Then<br />
If c = 1300 Then c = 1299<br />
DrawWidth = DrawWidth + 1<br />
c = c + 1<br />
Label1.Caption = c<br />
If c = 1300 Then c = 1299<br />
End If<br />
If KeyAscii = 45 Then<br />
If c = 1 Then<br />
Else<br />
DrawWidth = DrawWidth - 1<br />
c = c - 1<br />
If c = 0 Then c = 1<br />
Label1.Caption = c<br />
End If<br />
End If<br />
If KeyAscii = 48 Then<br />
DrawWidth = 1<br />
Label1.Caption = "1"<br />
c = 1<br />
End If<br />
If KeyAscii = 63 Then<br />
j = InputBox("Input a line width 1 - 1300", "Line Width", c)<br />
If j > 1300 Or j = 0 Then<br />
j = InputBox("Input a line width 1 - 1300", "Line Width", c)<br />
KeyAscii = 63<br />
Else<br />
c = j<br />
Label1.Caption = j<br />
Form1.DrawWidth = j<br />
End If<br />
End If<br />
End Sub<br />
<pre>
Private Sub Form_Load()
Label1.Caption = "1"
c = 1
Timer3.Interval = 1
Timer4.Interval = 1
AutoRedraw = True
End Sub</pre><br />
<br />
<br />
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<br />
' Let MouseMove know we are drawing.<br />
Drawing = True<br />
<br />
' Start from scratch<br />
Timer3.Interval = 1<br />
Timer4.Interval = 1<br />
' Start drawing here.<br />
CurrentX = X<br />
CurrentY = Y<br />
End Sub<br />
<br />
<pre>Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Make sure we are drawing.
If Not Drawing Then Exit Sub
' Save the new point.
NumPoints = NumPoints + 1
ReDim Preserve PointX(1 To NumPoints)
ReDim Preserve PointY(1 To NumPoints)
PointX(NumPoints) = X
PointX(NumPoints) = X
Timer3.Interval = 1
Timer4.Interval = 1
' Draw to the point.
Line -(X, Y)
End Sub
</pre><br />
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)<br />
' Stop drawing.<br />
Drawing = False<br />
<br />
End Sub<br />
<br />
<br />
Private Sub Option2_Click()<br />
End Sub<br />
<br />
Private Sub Form_Terminate()<br />
c1 = vbBlack<br />
c2 = vbBlack<br />
Unload Me<br />
End<br />
End Sub<br />
<br />
<pre>Private Sub Form_Unload(Cancel As Integer)
Unload Me
End
End Sub
Private Sub Label2_Click()
Form2.Visible = True
Form1.Enabled = False
End Sub</pre><br />
<br />
Private Sub Timer1_Timer()<br />
frmSplash.Visible = True<br />
frmSplash.Enabled = True<br />
Timer2.Interval = 1<br />
Timer1.Interval = 0<br />
End Sub<br />
<br />
<pre>Private Sub Timer2_Timer()
Timer1.Interval = 0
frmSplash.Timer1.Interval = 0
Form1.DrawWidth = Label1.Caption
Label1.Caption = Form1.DrawWidth
End Sub</pre><br />
<br />
<br />
Private Sub Timer3_Timer()<br />
If c1 = Form1.ForeColor Then<br />
Form1.ForeColor = c2<br />
Timer3.Enabled = False<br />
Timer4.Enabled = True<br />
End If<br />
End Sub<br />
<br />
<pre>Private Sub Timer4_Timer()
If c2 = Form1.ForeColor Then
Form1.ForeColor = c1
Timer4.Enabled = False
Timer3.Enabled = True
End If
End Sub</pre><br />
<big>if you find an answer or you need or would like either programs, just emai me on;</big> <br />
<br />
<div class="ForumSig">David Gee - david-gee@hotmail.com</div>
|
|
|
|