|
What's easier than that ? This is still programming, we still need to write code. Any movable object, I would simply draw it in the paint event, and change the location and invalidate during mouse move if it's being moved.
You can use CreateGraphics to draw a dragged object if yuo like, but I don't see the benefit.
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 have developed an application to zip the file using shell32.dll file and natively zipped the file now i want to encrypt the file with password ie.,same as how we provide password to the zipped files
i want to do this programmatically can anyone please help me out in this regard it will be great help!!!
Thanking You in advance
nagashree
|
|
|
|
|
The shell does not support this, you'll need a third party library to do that.
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 )
|
|
|
|
|
Quote
The WinZip Command Line Support Add-On is a FREE add-on for users of WinZip Pro with a valid license. Before installing this add-on, please make sure you have WinZip Pro installed.
The WinZip Command Line Support Add-On provides a command line interface that gives you the power of WinZip without the usual WinZip graphical user interface. It allows you to use WinZip directly from the command prompt and from batch (.BAT) files and script languages, making it ideal for automating repetitive tasks. An extensive set of command line options gives you pinpoint control over WinZip's actions. And, in automated environments, end-users need not know anything about how to use WinZip.
Thats a wrap!
Autodev
|
|
|
|
|
If my application is Windows Form I just use App.StartUpPath,But if it is class library can i get path of library.
|
|
|
|
|
Hi,
you will need the Assembly class, get the assembly instance you are interested in
(maybe with GetExecutingAssembly), and look at one of its properties (probably Location).
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thank you Luc Pattyn you help me again.
|
|
|
|
|
Hello,
I am trying to complete a small project in VB, but am having a problem figuring out how to handle a button click within the event of a current button click. The book I am using is not very descriptive in this case and I can't find any other examples with like code. I have most of the project complete, but I am stumped on the extra button click handling part of it. Most projects I have completed just gathered information from textboxes etc, but this is the first that asks for input from another button click and I can not find any examples. I need to have small button click converted into the numbers 1, 2, and 3 respectively so that when the button is clicked, the program will subtract that number from the total and then go back and decide whose turn it is.
The book I am using is: Visual Basic 2005 6th edition by David Schneider
Here is the project requirements:
Write a program that allows the user to challenge the computer to a game of pick-up-sticks. Here is how the game works. The user chooses the number of matchsticks (from 5-50) to place in a pile. Then, the computer chooses who will go first. At each turn, the contestant can remove one, two, or three matchsticks from the pile. The contestant who chooses the last matchstick loses.
The computer should make the user always select from a pile where the number of matchsticks has a remainder of 1 when divided by 4. For instance, if the user initially chooses a number of matchsticks that has a remainder of 1 when divided by 4, then the computer should have the user go first. Otherwise, the computer should go first and remove the proper number of matchsticks. (Note: The remainder when n is divided by 4 is (n Mod 4)) After writing the program, play a few games with the computer and observe that the computer always wins."
My Code So Far:
Public Class frmGame
Private Sub btnRules_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRules.Click
MsgBox("If you would like to play a game of Pick up Sticks, you must first choose a number of sticks from 5-50 to be placed into the pile, then when it is your turn you may select 1, 2, or 3 as the number of sticks to take from the pile. The contestant who chooses the last matchstick loses. Click Begin a New Game to get started.", 0, "Rules")
End Sub
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
Dim sticks As Double
Dim one As Double
Dim two As Double
Dim three As Double
GetInput(sticks, one, two, three)
DisplayStatus(sticks, one, two, three)
End Sub
' Private Sub btnOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOne.Click
'Dim sticks As Double
' Dim one As Double
' Dim two As Double
' Dim three As Double
'CalculateSticksOne(sticks, one, two, three)
' DisplayStatus(sticks, one, two, three)
' End Sub
Sub GetInput(ByRef sticks As Double, ByRef one As Double, ByRef two As Double, ByRef three As Double)
'calculate which user goes first
sticks = InputBox("Please enter how many sticks the pile should begin with. Choose a number from 5-50.", "Choose number of Sticks")
End Sub
' Sub CalculateSticksOne(ByRef sticks As Double, ByRef one As Double, ByRef two As Double, ByRef three As Double)
' one = 1
' End Sub
Sub DisplayStatus(ByVal sticks As Double, ByVal one As Double, ByVal two As Double, ByVal three As Double)
Dim pile As Double
pile = CalculatePile(sticks, one, two, three)
If pile = MsgBox("It is your turn to choose.", 0, "Pick up Sticks") Then
pile = sticks
txtPile.Text = pile
Else
txtPile.Text = pile
End If
End Sub
Function CalculatePile(ByVal sticks As Double, ByVal one As Double, ByVal two As Double, ByVal three As Double)
Dim status As Double
If sticks Mod 4 = 1 Then
status = MsgBox("It is your turn to choose.", 0, "Pick up Sticks")
Else
status = sticks - 2
End If
Return status
End Function
End Class
-------------
If anyone has any suggestions on how to handle the three small button clicks within the main program click, please let me know! I can not locate this information in the text book and have not been able to find help anywhere else. I think once I can figure out how to code those button clicks, I should be able to be ok as I know I am missing the code where the computer wins, but can code that later. For reference, know that I am expected to utilize sub procedures and functions when appropriate in my programs at this point so I can not eliminate them.
If you would need my project.vb and project.design.vb to look at, please let me know!
Thank you so much in advance!
Erin0201
|
|
|
|
|
I think you mean that you want a member variable to store a number and that number changes when you click the button ? So it remembers it's last value and then changes on the click ?
Public Class frmGame
dim i as int = 0
Private Sub btnRules_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRules.Click
I don't do VB ( it's nasty as hell ), but I think this syntax is correct. Certainly, if you declare a variable outside of any method, it's a member and will be visible to all methods, and keep it's value between method calls.
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 )
|
|
|
|
|
I have been searching for a solution on using a custom cursor within a program I am writing. I would like to place a custom cursor (say PickBox.cur) in the resource folder that is located in the Solution Explorer and access it from the program by using the following code...
Me.cursor=My.Resources.Pickbox
When I try doing this, it gives me an error "Value of type '1-dimensional array of Byte' cannot be converted to 'System.Windows.Forms.Cursor'."
I can use a similar method as noted above to access icons in the resource folder, but for some reason it does not like working for cursors.
Could someone please help me out on solving this problem. I have searched the internet, and web sites, but have not found a solution that actually worked.
Any help would be greatly appreciated.
Thank you!
|
|
|
|
|
Do you need to cast it to System.Windows.Forms.Cursor before assigning it?
|
|
|
|
|
Thank you for the help, but not sure what you mean by "cast". sorry. I searched for help on this, and still nothing. Can you give me an example?
Thank you.
|
|
|
|
|
Do While MyReader.Read<br />
ComboBox97.Items.Add(MyReader.GetString("0"))<br />
Loop
their error in this statment
the error is "Specified cast is not valid".
please what is it mean and how i can cover from it
|
|
|
|
|
You might want to describe what you want this code to do, because it doesn't make a whole lot of sense right now.
It looks like you're trying to read a stream of characters, one by one, and adding each character to a combobox as a seperate item. Is this really what you want??
|
|
|
|
|
MyCmd.Connection = con<br />
MyCmd.CommandType = CommandType.Text<br />
MyCmd.CommandText = "SELECT SectionID FROM([Section]) WHERE (CourseID = '" & ComboBox96.Text & "')"<br />
MyReader = MyCmd.ExecuteReader<br />
Do While MyReader.Read<br />
ComboBox97.Items.Add(MyReader.GetString("0"))<br />
Loop<br />
<br />
MyReader.Close()
i am reading from database sectionid and i fill it to combbox
i do this with deferent data and it work but in this statement it give the error
can you help me
it dos not giv error in the fllowing code
g1 = ComboBox95.Text<br />
Dim MyCmd As New OleDbCommand<br />
Dim MyReader As OleDbDataReader<br />
con.Open()<br />
MyCmd.Connection = con<br />
MyCmd.CommandType = CommandType.Text<br />
MyCmd.CommandText = "select DISTINCT CourseID from Course where LevelNo=" & g1<br />
MyReader = MyCmd.ExecuteReader<br />
Do While MyReader.Read<br />
ComboBox96.Items.Add(MyReader.GetString("0"))<br />
Loop<br />
MyReader.Close()<br />
con.Close()
|
|
|
|
|
MyCmd.CommandText = "SELECT SectionID FROM([Section]) WHERE (CourseID = '" & ComboBox96.Text & "')"
change to:
MyCmd.CommandText = "SELECT SectionID FROM [Section] WHERE CourseID = '" & ComboBox96.Text & "'"
|
|
|
|
|
thinks but it dos not work
the same error "Specified cast is not valid"
the query i use it in other place and it work
i don't think the error from the query
|
|
|
|
|
asha_s wrote: MyReader.GetString("0"))
Doesn't that take an Integer as varaible?
|
|
|
|
|
i use the same with the same statment with the same argument and it work
|
|
|
|
|
im doin my project which using file stream to keep the videos into DB
but when i want to show them on my website by using Media player
it juz can play only small size of video like 3MB
but my data will be more than 50MB which cannot be show up
so any idea?
|
|
|
|
|
There's got to be something else wrong because there is no limit to the file size that can be played.
For a file that large, I'd probably recommend serving up that content using MS Media Server instead of an HTTP file download.
|
|
|
|
|
Hi freeks
i have a little problem: so i have a array of value which looks like
0 0 0 0 0 0 2 3 9 8 1 4 5 0 0 0 0 0 0 0 5 4 6 4 8 4 3 0 0 0 0 0 0 5 4 3 2 2 1 0 0 0
what i want is to get the max value in every block of values between the nulls and his Index;
so that i get like this result : in this case just in hashtable(whithout to write "value" and "Index" like strings i mean)
value Index
9 --> 8
8 --> 24
5 --> 33
normally the values comes once in a block; this just an simple example.to know how it works.
thy a lot fiends
|
|
|
|
|
This isn't as complicated as you make it sound. All you have to do is put this array through a method that looks for blocks of numbers, bracketed by 0's. Then you run each block through another method that returns the highest number in that block. I simple scan of all the values, keeping track of the highest value you saw should do it.
|
|
|
|
|
thx first
could you wrtite me an example to see how it could be? i m a little noob (
thx brother
|
|
|
|
|
If I wrote it for you, you wouldn't learn anything.
But, here's a pseduo-code layout of how you can do it:
GetMaxValueInArray
currentMaxValue = 0
For element in the array
If element(i) > currentMaxValue
currentMaxValue = element(i)
End If
Next
Return the currentMaxValue
|
|
|
|
|