|
Sorry I forgot to type it. Just assume that it is there. It is still not functioning.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Try this where the changes are in bold:
Dim XData as New MetaData
XData = MetaDataFactory.GetMetaData ("FileNameGoesHere")
Artist = XData.Artist 'Doesn't return the value.
....
Public Class MetaDataFactory
Public Shared Function GetMetaData(ByVal filename As String) As MetaData
Dim XX as new MetaData
xx.Artist = "BOB MARLEY"
GetMetaData = xx
End Function
End Class
Regards
David R
|
|
|
|
|
JUNEYT wrote: Sorry I forgot to type it. Just assume that it is there. It is still not functioning.
Paste the actual code that you are using. It's very hard to find the error in the code that you are using by looking at some other code that you are not using...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
In the GetMetaData method you create an instance of the MetaData class, put some data in it and throw away the instance.
Then you create a new instance of the MetaData class, and you expect it to contain the data that was in the instance that you threw away.
Do you see the problem?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
I have passed several types of variables as (Byte,String,int32 and etc.) into a function. The my aim is to get the value of passed variable and check to see if it is null or not. If it is null, The function should return "Undefined" as a string. If it is not, it should assign the variable's original value to function.
I have no idea how to run the function for several types of variable and get their value and assign it to the function. The vb.net is no longer supporting variants.
Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
I'm assuming that there is only one function with one parameter.
Make the function's parameter an object. Then in the function use a series of if statements with typeof...is operator.
The function would have to return an object since you don't know whether it is a string or other type.
It's not pure OO but would do the job. Some sample of your code would help to get a better answer.
Regards
David R
|
|
|
|
|
Public Function ToStringStuff(ByVal someNumber As Nullable(Of Integer))
If (someNumber.HasValue) Then
Return someNumber.ToString()
Else
Return "Undefined"
End If
End Function
Public Function ToStringStuff(ByVal someBool As Nullable(Of Boolean))
If (someBool.HasValue) Then
Return someBool.ToString()
Else
Return "Undefined"
End If
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As Nullable(Of Integer) = Nothing
TextBox1.Text = ToStringStuff(a)
End Sub
Something like this?
I are troll
|
|
|
|
|
Better answer than my off-the-top-of-the-head reply.
Regards
David R
|
|
|
|
|
Thank you so much! Fantastic sample.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
You're welcome
I are troll
|
|
|
|
|
Hey,
I have some problems with the KeyDown event. When a user keeps a key pressed, the KeyDown event keeps being fired. I don't want this to happen, I just want to trap it once so I know that the key is pressed. I use the KeyUp event to check if the key is released.
Can somebody help me out on this one?
Zaegra
Motivation is the key to software development.
|
|
|
|
|
Could you add a boolean flag and set it to true in key down and to false in key up. If the flag is true, ignore the event. Something like this in keydown:
if (keydown = false) then
keydown = true
... your other code ...
end if
and in keyup
keydown = false
|
|
|
|
|
You can't stop the event being fired.
What you could do is declare a boolean variable, e.g. keyIsDown, and set it to true in the KeyDown handler and false in the KeyUp handler. The variable would then be used to control whatever you're doing in the handlers.
Without knowing exactly what you are rying to do I can't suggest anything else.
Regards
David R
|
|
|
|
|
Well, I'd like to trap Key Combinations like Alt+F4 etcetera but I can't find a way to do this, because the event keeps being fired, so I get 20x Shift and 1x F4 Any suggestions on how to trap Key Combinations?
Motivation is the key to software development.
|
|
|
|
|
I'm a bit hazy on this since I've not used Key events for some years.
But here's my suggestion.
When KeyDown fires store the key code in a variable (as well as setting keyIsDown flag).
When the event fires again, if the current key code is same as previous just ignore it. When the code changes do whatever you have to.
One thing that stopped me using key events is that generally I wouldn't want to change the behavior of standard key combinations like Alt=F4.
Regards
David R
|
|
|
|
|
Are you checking them both at the same time, or one after another? The event gets fired alot, but firing an event doesn't eat away too much CPU-time. If you only need the combination of the keys, then try this;
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If (e.KeyCode = Keys.F4 And e.Shift) Then
MessageBox.Show("Hit it, Sam!")
End If
End Sub
I are troll
|
|
|
|
|
Hi,
don't try anything that adds state variables (such as a KeyIsDown variable) since that is bound to fail under special circumstances (e.g. when the app looses focus in between a key going down and up again, the state variable will be incorrect on the next KeyDown, which then won't get processed since KeyIsDown is still true...)
You don't need to track the modifier keys (ALT, CTRL, SHIFT) at all, the system does that for you: you can get their immediate value at all times; in particular there is Control.ModifierKeys which always reflects the current situation; but there is even better: each KeyDown event has a KeyEventArgs which holds properties Alt, Control, Shift.
So simply check the key is F4 and Alt is true.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I have this code written in VFP, I converted to VB.net and it seem it is working
If any one has any comment on the code about what should I use or not use or he have better idea, please say so
' This program capture CTRL+SHIFT, it can be changed to capture any combination
' Add Timer ,Command button to the form
' In the declaration
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer)
Declare Function GetKeyState Lib "user32" Alias "GetKeyState" (ByVal nVirtKey As Long) As Integer
Const VK_SHIFT = &H10
Const VK_CONTROL = &H11
'Button1_Click
Me.Timer1.Interval = 1
Me.Timer1.Enabled = True
' After clicking, try to press CTRL+SHIFT or SHIFT+CTRL
' Timer1_Tick
Dim nKeySHIFT, nKeyCTRL
nKeySHIFT = GetKeyState(VK_SHIFT)
nKeyCTRL = GetKeyState(VK_CONTROL)
If nKeySHIFT <> 0 And nKeySHIFT <> 1 And nKeyCTRL <> 0 And nKeyCTRL <> 1 Then
MessageBox.Show("SHIFT + CTRL is pressed")
Timer1.Enabled = False
End If
Samir R. Ibrahim
|
|
|
|
|
Hi,
I wrote a program and I want to do a check with the version that is on the internet.
I create and adapt the file on the webserver when I have a new version
now I use:
wc = New Net.WebClient
Dim version As Byte() = wc.DownloadData(UriVersion)
Dim sHTTPver As String = System.Text.ASCIIEncoding.ASCII.GetString(version)
Dim vnCurrentVersion As System.Version = Functions.fgetProgramVersionNumber()
Dim nVersion As Double = Val(vnCurrentVersion.Build & "." & vnCurrentVersion.Revision.ToString("00000"))
Dim nhttpVer As Double = Val(sHTTPver)
Function fgetProgramVersionNumber() As System.Version
Dim VersionNo As System.Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version()
Return VersionNo
End Function
this lines of code to check is there is a newer version.
however this methode seems not to increment all the time. When I compile on another computer it decrease. how can I have a beter control over the version with a automatic incresed number
|
|
|
|
|
OK, why are you going through all of this?? Why not just send the current program name and version number to a webserver on your server that responds with a True or False if there is a newer version? Then, you can download the latest version of the file and replace your application.
It seems like you're putting all the version checking code into the application itself when it should be on the server side.
|
|
|
|
|
Hi,
I think I need to write some phpcode to do that?
I think I have to update some DB on the server side also.
I never hade take a look on php nor asp
Jan
|
|
|
|
|
No, you don't need PHP to do that. If you've got IIS as a webserver, you can use C#, VB.NET, or any other .NET targeted language to do it. If you don't have IIS, then you can use Java.
jan212r wrote: I think I have to update some DB on the server side also
Why? The code is getting the new version from the server already, so there shouldn't be anything you change on the server. The WebService code would just use that same number as the new version.
|
|
|
|
|
Hi
I have trouble with ADO.Net. I don't understand when to use what. I'm using Visual Basic in Visual Studio 2005.
In my program I have a dataadapter-,dataset and a bindingsource control.
When I try to use the code
Dim cnNwind As New OleDb.OleDbConnection(Me.FilmTableAdapter.Connection.ConnectionString)
Dim cmOrder As OleDb.OleDbCommand = Nothing
Dim strSQL As String = "DELETE FROM " + table + " WHERE ID = " + cbo.SelectedValue.ToString
cmOrder = New OleDb.OleDbCommand(strSQL, cnNwind)
cmOrder.ExecuteNonQuery()
nothing happens, the record isn't deleted.
I have also tried using the adapters Delete method
Me.FilmTableAdapter.Delete(cbo.SelectedValue.ToString)
Me.FilmTableAdapter.Update(Me.FilmerDataSet)
and nothing happens.
I don't know if I had to use the update method, but it didn't mattered if I did or didn't.
I have also tried to add parameters when I used the Delete method, but it didn't helped.
cmOrder.Parameters.AddWithValue("@Original_ID", cbo.SelectedValue.ToString)
Me.FilmTableAdapter.Delete(cbo.SelectedValue.ToString)
So I have know clue what to do or when I should use either of the methods to delete a record.
If there is somone who can explain when to use either of these examples, please explain that for me. And when should I use the update method, because I don't know.
And what should I do in my program to delete a record.
PLEASE HELP ME!!!!
FIA
|
|
|
|
|
you have to call cnNwind.Open() before executing a command.
Calin
|
|
|
|
|
Sorry, I didn't paste that line. I have already used the code.
cnNwind.Open()
before I used the ExecuteNonQuery or the dataapter's Delete method and it still doesn't work.
|
|
|
|