|
You are right.
I trying to reproduce all the scenario how it will work but I still have a problem in this way because also in your way I will need to use reflection.
This is the scenario:
I have an enum:
public enum criterias
criteria1
criteria2
criteria3 ...
end enum
From my database I need to know for each user which criteria is linked to.
My database example:
Col1: UserID {1,2,3,4}
Col2: Criteria (Criteria1,Criteria2,Criteria1,Criteria3}
Public function f()
'returns for each user wich criteria
criteriaFromDb=LoadCriteriaFromDb
select case criteriaFromDb
case criterias.criteria1
call f1
case criterias.criteria2
call f2
case criterias.criteria3
call f3
end case
end function
If I am right until this line, so criteriaFromDb is a string that I pull out from Mydatabase and now I still need to "convert" it to enum (I know how to do this) and it is actually same as "converting" string to function.
Thanks
Shay Noy
|
|
|
|
|
shaynoy wrote: I still need to "convert" it to enum (I know how to do this) and it is actually same as "converting" string to function.
Not at all. You make sure your enum has int values that correspond to the int values stored in your DB, and you just cast it. No reflection needed.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
Now it is clear, thank you very much
Shay Noy
|
|
|
|
|
I have used delegate functions for something like this, the database actually holds the method name but the methos must have the same footprint. I'll see if I can find the code tomorrow.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I'm having a problem with a contextmenustrip control. This menu appears when the user is right clicking on a control. When the click event of a first-level contextmenu item is called, I can use the sourcecontrol property in order to retrieve the control that has been clicked. However, when I the click event of a second-level contextmenu item is called, the program is not able to retrieve the right control. The program crashes and give me the following error: System.NullReferenceException.
Any help is welcome.
Gabriel
|
|
|
|
|
Hi,
i've a problem with string evaluation.
I need a function that return me the value of a variable passed throught his name...something like this:
<br />
Public Variable As Integer = 2<br />
<br />
<br />
Function Evaluate(ByVal name as String)<br />
End Function<br />
<br />
Evaluate("Variable") -> this have to return me the value 2<br />
Thanks
|
|
|
|
|
Function Evaluate(ByVal name as String) as Int32<br />
try<br />
return convert.toInt32(name)<br />
ctach ex as exception<br />
return 0<br />
end try<br />
End Function
Ashish Sehajpal
|
|
|
|
|
thanks!
Another question, if i want to process also String variable like this:
Public Variable as String = "abcd"
Evaluate("Variable") -> this must return abcd
Thanks
|
|
|
|
|
If I understood right, you say that passing as parameter the name of the variable to the function and converting it to int32 will return its value?
It is wrong or I perhaps miss something. Do you mean that this following code is running? Otherwise, please show your code.
Public Variable As Integer = 2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(Evaluate("Variable"))
End Sub
Function Evaluate(ByVal name As String) As Int32
Try
Return convert.toInt32(name)
Catch ex As Exception
Return 0
End Try
End Function
Shay Noy
|
|
|
|
|
First, ask yourself why you want to do this.
If you need to maintain a disperate group of variable values by name then perhaps you should use a dictionary, i.e.
Dim myVariables As New Dictionary(Of String, Object)()
myVariables.Add("myVarName", 2)
...
Dim i As Integer = DirectCast(myVariables("myVarName"), Integer)
If you really need to maintain class level fields then you'll have to use reflection to access the values dynamically, and you'll need a reference to the encapsulating class.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Hi there,
i have a little issue with form deactivation:
i use 3 forms: background form (form1), image form (form2) and list form (form3). i want to hide these forms when the background form (form1) gets deactivated but not when it gets deactivated by the other 2 forms.
that's how i start my application:
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
form2.show(Me)<br />
form3.show(Me)<br />
End Sub<br />
can anyone tell me a solution?
Thanks a lot.
|
|
|
|
|
your going to have to use a form manager(make your own) where you make calls into it via the activate/deactivate events of each form. then depending on who activate/deactivated show and hide form2 and 3...
hope this helps
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
How do I set the caret position in a textbox?
|
|
|
|
|
textbox.selectionstart/textbox.selectionlength
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Hi ..
Im looking for work out a way i can do math calculations in reportviewer. i've had a bit of a play and google somewhat but i think ill need someone to really tell it to me straight.
basically im looking to say do math caculation between to fields that the reportviewer generates.
so basically
col1 col2 col3 [calc amouts]<--- these column needs to calc all
10 5 15
20 10 45
30 15 90
i want col3 to continually do sums for each row without resetting
its previous amount.
hope this is clear some what..
thanks
Regards
Robbo
|
|
|
|
|
hi there..
i assume that u know how to use formula field.
so i'l gonna solve your problem as:
use a variable which stores the value of the previous row result and then add this variable to the sum of the current row result.
i hope you got it..!
J A Nasir K
|
|
|
|
|
Hi All,
I working on developing a windows application, i want to give user the permission to compress a specific directory and i want to knw how do we achieve it.
Note: I want to compress a Directory\Folder.
Thanks and regards,
Ashwin.
|
|
|
|
|
A quick google search for " vb.net compression" provides a range of pages dealing with that subject, some of them even with code examples.
278.000 results for vb.net compression. (0,08 seconds).
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Hi,
I´d like to save a file in an oracle database over oledb. The code was allready running for sql only. But it has also to work with oracle. So i changed my connection from sql to oledb. But since that it don´t work with booth. Something is wrong with the parameter @data in booth cases. Has anybody an idea?
Private Function SQL_Save_this_PDF(ByVal selection As String, ByVal where As String) As Boolean
Dim oledbConn As OleDbConnection
If Not CcPdfViewer1.pdffile = "" Then
Dim id As String = ""
Dim bindata As Byte()
Dim strm As IO.Stream
Dim filename As String = CcPdfViewer1.pdffile
strm = New IO.FileStream(filename, IO.FileMode.Open, IO.FileAccess.Read)
ReDim bindata(strm.Length - 1)
strm.Read(bindata, 0, strm.Length)
strm.Close()
filename = My.Computer.FileSystem.GetName(filename)
If dbms = "oracle" Then
oledbConn = New OleDbConnection("Provider= OraOLEDB.Oracle; Data Source=" + server + "; User ID=" + database_user + "; Password=" + database_pwd + ";")
Else
'mssql
oledbConn = New OleDbConnection("Provider= sqloledb; Data Source=" + server + ";Initial Catalog=" + database + "; User ID=" + database_user + "; Password=" + database_pwd + ";")
End If
Try
oledbConn.Open()
Static save_pdf As OleDbCommand
save_pdf = New OleDbCommand("Insert into dateien (id,name,data) values ('" + id + "','" + filename + "',@data)", oledbConn)
save_pdf.Parameters.Add("@data", OleDbType.LongVarBinary)
save_pdf.Parameters("@data").Value = bindata
save_pdf.ExecuteNonQuery()
Thanks, Daniel
Catch e As OleDbException
MsgBox(e.Message)
oledbConn.Close()
Return False
End Try
bindata = Nothing
End If
Return True
End Function
|
|
|
|
|
Found it. Just change the parameter @data in the oledbcommand to "?".
|
|
|
|
|
Hi all,
Now i am working with a checkedlistbox. Can i sort the checked items in a checkedlistbox. In other words , I want to display the checked items in the top of the checkedlistbox. Any suggestions would be appreciated
Thanks
Sebastian
|
|
|
|
|
Sounds like you'll have to load the checked items into a list, then the unchecked items into another list, then clear the checkedlistbox, then add items to it first from the checked items list, and then the unchecked items list.
|
|
|
|
|
|
Is it possible to merge two RTf files into one...
Please post any reference links or sample code...
Jats
|
|
|
|
|
You are really annoying. You asked a question like this just a few hours ago.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|