|
Hi,
why is TimeWorked declared a String???
did you look at its value after execution of TimeWorked = 100 / 100 ?
either print it out, or single-step your program (set a breakpoint!)
where are Time1/2/3/4 set to specific values?
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.
|
|
|
|
|
Luc,
I have tried different approached, including the below:
Dim TimeWorked As Single
Dim Time1 = updTime1.Text
Dim Time2 = updTime2.Text
Dim Time3 = updTime3.Text
Dim Time4 = updTime4.Text
Dim Rest As Single
My desire is to be able to progressively calculate the unalloacted time as the user inputs a value in each of the updTimex fields.
IT
|
|
|
|
|
which isn't good either, you want all variables having the same type (say Single), so Time1/2/3/4
should also be Single; then you better explicitly convert the String that is in TextBox.Text
to a Single, probably using Convert.ToSingle().
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.
|
|
|
|
|
Just wanted to close the loop on this; I got it working as desired. Thanks Luc.
Private Sub updTime1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updTime1.ValueChanged, updTime2.ValueChanged, _
updTime3.ValueChanged, updTime4.ValueChanged
Dim TimeWorked As Decimal
Dim Time1 = Convert.ToDecimal(updTime1.Text)
Dim Time2 = Convert.ToDecimal(updTime2.Text)
Dim Time3 = Convert.ToDecimal(updTime3.Text)
Dim Time4 = Convert.ToDecimal(updTime4.Text)
Dim Rest As Decimal
TimeWorked = Time1 + Time2 + Time3 + Time4
'unallocated time across projects
Rest = (100 - TimeWorked) / 100
If Rest > 0 Then
Me.lblMessage.Text = FormatPercent(Rest) & " of your Time is still unallocated."
Else
Me.lblMessage.Text = ""
End If
End Sub
|
|
|
|
|
You're welcome.
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.
|
|
|
|
|
Just a ?
Dim TimeWorked As Decimal This is obviously decimal
Dim Time1 = Convert.ToDecimal(updTime1.Text) Would this not be an object (admittedly with a type decimal as content)
And the rule is.... NO BLOODY VARIANTS
Dontcha love the old VB style, just declare the dammed thing I just want to use it not dance it round the room!
|
|
|
|
|
Mycroft Holmes wrote: Would this not be an object
yes
Mycroft Holmes wrote: Dontcha love the old VB style
no
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.
|
|
|
|
|
I need to know how to do two things.
How do I make it so that no date at all is the default date in a date time picker. I noticed that the date time picker displays the current date by default.
How do I set the date to a particular date using a date time picker. I will get the date from a database and put it into a dataRow.
|
|
|
|
|
1 - I don't think you can, it needs to show *something*
2 - I expect you set the same property ( Value, perhaps ) that you get after it's been shown to see what was selected.
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 )
|
|
|
|
|
1. Are you talking about nullable datetime picker? There are a few articles here.
2. You set the datetime picker's Value property, or do a databinding.
|
|
|
|
|
Hello experts!
I've ran into a problem in my VB.NET coding. I've created a form with no border and is painting it with pixels-transparent PNG images using UpdateLayeredWindow. At the moment, the form is moving using the "caption" function in WndProc, the NCHITTEST thing..
The problem is, that it want to make the form able to "snap" to other forms also painted with UpdateLayeredWindow. I've already tried a lot:
Protected Overloads Overrides Sub WndProc(ByRef m As Message)<br />
Select Case m.Msg<br />
Case 512 ' mouse move<br />
<br />
If ((Me.Location.Y + Me.Height) > (frmEvent.Location.Y - 10) And (Me.Location.Y + Me.Height) < (frmEvent.Location.Y + 10)) Then<br />
Me.Location = New Point(Me.Location.X, frmEvent.Location.Y - Me.Height)<br />
'MsgBox("yes")<br />
End If<br />
Case 70 ' windows position change<br />
drawstring += 1<br />
<br />
If ((Me.Location.Y + Me.Height) > (frmEvent.Location.Y - 10) And (Me.Location.Y + Me.Height) < (frmEvent.Location.Y + 10)) Then<br />
Me.Location = New Point(Me.Location.X, frmEvent.Location.Y - Me.Height)<br />
'MsgBox("yes")<br />
End If<br />
Case 132 ' NCHITTEST<br />
m.Result = New System.IntPtr(2)<br />
If ((Me.Location.Y + Me.Height) > (frmEvent.Location.Y - 10) And (Me.Location.Y + Me.Height) < (frmEvent.Location.Y + 10)) Then<br />
Me.Location = New Point(Me.Location.X, frmEvent.Location.Y - Me.Height)<br />
'MsgBox("yes")<br />
End If<br />
Return<br />
End Select<br />
MyBase.WndProc(m)<br />
End Sub
However, this does not work (the example only includes snapping to the top of another form called frmEvent). When I move the form above the other form, it sometimes "blinks". If it doesn't blink, it will just do nothing. When I have the form where it is supposed to snap, it will first be snapping when i release the mouse.
Can anyone help me here?
Greetings..
|
|
|
|
|
Hello...
i need help wid user input via a table.Searched high n low,but got no solution.
My problem: i want the user to TYPE in data into a table (or table like structure,dat looks like a data grid) and then, on the click of the save button,the data is saved to the database i.e into the actual table in the database.
for example:
name age state country
---
---
---
---
and so on
|--------------|
| SAVE |
|--------------|
....all done at the front end,in order to simulate data entry into an actual table.
How do i do dis?????
Data grid has dat kind of structure...sadly it takes no input.
Can anyone temme how dis cud b accomplished?
Hmmm....VB.net must have some visual 'table' like control,like there is in microsoft word and excel,dat cud make data entry of dis sort possible...
there's something for a treeview,but no TABLE!!!!
|
|
|
|
|
wid and dat are not words. Neither is temme, dis, cud, or b. We are grown ups here, we're not 7.
Perhaps if you used english when you typed stuff into google, you'd find the various grid controls. Of course, you need to write some code to stuff those values into your databaser.
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 am working on a program that stores peoples data, only while the program is running thouugh. I want to create an array to store thier details. I want to store 10 users details. I have:
txtName = Their Name textbox
txtAddress = Their address textbox
txtAddress1 = Their address textbox
txtAddress3 = Their address textbox
txtPhone = Their phone number
I also want to store whats in cmbboxCar = car list combobox
I have a button called "txtStore" that will store the details when pressed, but don't know to do that.
I have a numericupdown = detnumber which when value is increased/decreased I want it to display whats stored in the current array index number. Say "5" was selected in the numericupdown, I want the details for person 5 to appear in all textboxes, comboboxes. But I want the updown to only go as high as the number of values stored. e.g. if 6 users details were stored, the numericupdown wont go higher.
Any ideas?
Thanks in advance
In the end we're all just the same
|
|
|
|
|
If you create a collection and insert the data, you can serialize the collection to disk and then load it again when the program restarts.
There are 100's of examples of this on the Internet. Very simple to do, just a few lines of code.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I have the array almost completed and stored array code in module (Bits of the code here):
<quote>Public txtRemainingBalance(10) As String
Public txtCustomerName(10) As String
Public txtAddress1(10) As String
Public txtAddress2(10) As String
Public txtAddress3(10) As String
Public txtRegNo(10) As String
Public txtCarModel(10) As String
Public ComboBox1(10) As String
Public txtPurchasePrice(10) As Decimal
Sub CalltxtCustomerName()
txtCustomerName(0) = "Not Defined"
txtCustomerName(1) = "Not Defined"
txtCustomerName(2) = "Not Defined"
txtCustomerName(3) = "Not Defined"
txtCustomerName(4) = "Not Defined"
txtCustomerName(5) = "Not Defined"
txtCustomerName(6) = "Not Defined"
txtCustomerName(7) = "Not Defined"
txtCustomerName(8) = "Not Defined"
txtCustomerName(9) = "Not Defined"
End Sub
Sub CalltxtAddress1()
txtAddress1(0) = "Not Defined"
txtAddress1(1) = "Not Defined"
txtAddress1(2) = "Not Defined"
txtAddress1(3) = "Not Defined"
txtAddress1(4) = "Not Defined"
txtAddress1(5) = "Not Defined"
txtAddress1(6) = "Not Defined"
txtAddress1(7) = "Not Defined"
txtAddress1(8) = "Not Defined"
txtAddress1(9) = "Not Defined"
The "Sub CalltxtCustomerName" and similar names just hold the "Not defined" text that displays when array is run.
On my third form, I have list boxes that display whats in the array in listboxes. Here is the code on the display button on that form:
<quote> ListName.Items.Clear()
ListAddress1.Items.Clear()
ListAddress.Items.Clear()
ListPostcode.Items.Clear()
ListCarReg.Items.Clear()
ListCarModel.Items.Clear()
ListCarCost.Items.Clear()
ListCarMake.Items.Clear()
Dim i As Integer
For i = 0 To 9
ListName.Items.Add(txtCustomerName(i))
ListAddress1.Items.Add(txtAddress1(i))
ListAddress.Items.Add(txtAddress2(i))
ListPostcode.Items.Add(txtAddress3(i))
ListCarReg.Items.Add(txtRegNo(i))
ListCarModel.Items.Add(txtCarModel(i))
ListCarCost.Items.Add(txtPurchasePrice(i))
ListCarMake.Items.Add(ComboBox1(i))
Now, all I want to do is on the form 1 and 2, make a button that stores whats in the text boxes and addes it to the index of the array, txtAddress1, txtAddress2 etc.. and adds that info into the next index number of the array and then clears the text boxes so that more data can be input and so on. I looked for examples, but can't find any. Any help would be appreciated.
In the end we're all just the same
|
|
|
|
|
Hi evrybody,
I want to create a program to play a sound or video stream by windows media player com object (= wmp) .
I have a wmp in my windows form.
I have a stream from that file(sound or video) not a path(file address on HD) .
I wery tried to find out some thing about this problem in internet.
----------------------------
hope to your help.
?
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
You cannot use the WMP to play from a stream in memory. It has to play from a file.
|
|
|
|
|
my problem in my programm is that i have a stream containig video or sound and i want to play it in my windows app via windows media player control .
this code can tell windows media player (=wmp) to play a file in internet
AxWindowsMediaPlayer1.Url = "some address";
this code meaning that wmp can play a video or sound streamly .
and my question is how can i play my stream when it is in memory ?
i find something about creating protocols to do something like the url passing to wmp
hope to your help.
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
For the second time, you can't. WMP will NOT play from a MemoryStream in your code. You MUST use a different control to do this, but I don't know of any.
|
|
|
|
|
|
Ive been searching through my ebooks and google literally for 5 hours now looking for a solution! Can anyone guide me on how to select a particular tab in a 3rd party application, either by the index number, or the tab name?
This selects the window I want to interact with:
<br />
Private Sub Button1_Click(...) Handles Button1.Click<br />
Dim Window As String<br />
Window = "PetDeviceMainDlg"<br />
AppActivate(Window)<br />
SendKeys.SendWait("%{F6}")<br />
End Sub<br />
And Ive tried every variation of this code from the MSDN (http://msdn2.microsoft.com/en-us/library/cdc8ebh8.aspx) that I can think of:
<br />
Private Sub Button1_Click(...) Handles Button1.Click<br />
<br />
Dim Window As String<br />
Window = "PetDeviceMainDlg"<br />
AppActivate(Window)<br />
SendKeys.SendWait("%{F6}")<br />
SelectTab(6)<br />
<br />
End Sub<br />
<br />
Public Sub SelectTab(ByVal index As Integer)<br />
<br />
Dim instance As New TabControl<br />
instance.SelectTab(index)<br />
<br />
End Sub<br />
When I debug, index does equal 6, but I get the error 6 isnt valid for index.
Any help would be much appreciated.
|
|
|
|
|
Tekkie wrote: Dim instance As New TabControl
instance.SelectTab(index)
A New TabConrol won't have any pages.
Seems like you are trying to select a Tab page in another application, correct?
If so, the SelectTab(6) is executing against your application and not the intended target application.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
If I take out the "new" i get the error "'instance' is used before it has been assigned a value". Im not sure why I had new in there, just picked it up from one of the google articles I think. How do I get it to keep focus on the other application? "Me." is for the VB form right?
Thanks
|
|
|
|
|
I think you miss the larger picture.
You can use SendKeys to send key strokes to another window.
But you can't write code in your application that executes in another window, especially if it's in another process.
Your tab selection code is running locally in your application but can't effect the other application or window.
modified 27-Feb-21 21:01pm.
|
|
|
|