|
this is function that i m using and it returns an integer
Public Function getavailableswitch(ByVal checkstr As String) As Int16<br />
....<br />
getavailableswitch = cmd.ExecuteScalar()<br />
end function
what i want is: to call the above function and
thus
Dim id As Integer<br />
If id = getavailableswitch(checkStr) <> 0 Then<br />
MsgBox(id)<br />
End If
i know it sounds very bad,
Note i want to do withing the "if" statement
1-the call statement
2-the test on retreived data from the function
thx for your help
Regards
Ramy
|
|
|
|
|
You already asked this in another thread and got the answer that works. But, how you've written your IF statement is actually comparing the value in id to the value returned by getavailableswitch . You're not making an assignment and then comparing that to 0. Start by simplifying your code and do the assignment outside of the IF statement:
Dim id As Integer
id = getavailableswitch(checkStr)
If id <> 0 Then
MsgBox(id)
End If
Also, your function should be changed to use a nice return type, instead of an Int16. You're not doing anything special to warrant using a smaller return type, so why bother...
Public Function getavailableswitch(ByVal checkstr As String) As Integer
....
Return cmd.ExecuteScalar()
End Function
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i asked in other thread.coz i thought that ther person who already replied to me will be offline now,and i wanted a reply fast..
Any way thx
Regards
Ramy
|
|
|
|
|
charchabil03 wrote: and i wanted a reply fast..
Then the forums are not the way to go. If you want a reply fast, do the research yourself or ask your prof. No forum guarantees any kind of a response time simply because we're not getting paid to do this. This is an entirely voluteer effort, and we all have lives outside of the CodeProject.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: Then the forums are not the way to go. If you want a reply fast, do the research yourself or ask your prof. No forum guarantees any kind of a response time simply because we're not getting paid to do this. This is an entirely voluteer effort, and we all have lives outside of the CodeProject.
Yes. It is amazing how many people think they are going to get a fast reply
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
What can i say oher than
Thx Guys
Regards
Ramy
|
|
|
|
|
Hi,
I have a Solution with multiple projects, one of which is the main program I was all the others to be launched from, an Integrator as such. I have set all the relevant build dependancies, however, is there a way to get Visual Studio to copy the output of each project from their bin folders, to the bin folder of the integrator project, for example using the pre-build/post-build events.
Thanks, Andrew Robinson.
|
|
|
|
|
All you have to do is create a batch file (.BAT or .CMD) that has the CMD commands to copy the files to where you want. THen you just launch that batch file in the Post-Build event.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dear Sir,
I am having problem with counting pulses from wheel sensor using
parallel port.
Using standard timer with 1ms interval to count pulses.
The problem is, it doesnt do counting the pulses continuosly.
Somebody told me to use threading.
Since i am not that good in programming, i dont know how to write
the code.
Could you please give me an example on how to read the pulses via
parallel port continuosly?
The pulses then is used to count odometer and speed of the car.
I am using a reed switch to generate the pulse. But it might make
noise, so i have to use a filter.
How do i do it?
How about a hall effect sensor?
Where should i connect it to the pin of parallel port?
Is serial port is bewtter? How to make it to serial?
I am using io.dll to read the parallel. What should i do to change
it to serial? What dll should be used?
Please help me.... I am stuck and could go nowhere here...
Thanks so much for helping me...
Regrads,
Tegar
|
|
|
|
|
You can't do what you want on the parallel port, period - end of story. This is because you have to poll for the status of the switch, instead of reacting to the change in state of the switch. Using polling, which is what you are limited to on the parallel port, you WILL ALWAYS miss changes in state of that switch. Why?
At any given speed, calculate how long the switch is contacted. How long does it take for the magnet to move under the leaf switch? How long does it take for that magnet to get the leaf to move and make contact? How long is that contact maintained once the magnet's influence on the leaf is lost? If your polling interval is longer than that value, and I guarantee it will be!!, you will missed the contact of the switch.
An example of the mechanics graphed out might look like this:
Time in milliseconds:
------1------2------3------4------5------6------7------8------9-----10-----11-----12-----13
Leaf Switch position:
Electrically Open
--------\ /--------\ /--------\ /--------\ /--------\ /--------
\ / \ / \ / \ / \ /
\----/ \----/ \----/ \----/ \----/
Electrically Closed
Polling interval (2ms):
-------------|-------------|-------------|-------------|-------------|-------------|----------
This assumes that your polling interval is dead on at 2ms. The switch won't read closed until the leaf makes contact, all the down in the graph above. See what's happening? You'll read the switch as closed at 2ms, but not at 4, 6, 8, and 10ms. Why? Because the switch isn't fully closed at the time of the read. At 4ms, it's almost closed, but hasn't quite made it. At 6 and 8, it's fully open. And at 10ms, the switch has started to return to open and is no longer fully closed.
This is why you need to make custom hardware that reacts to the change in state of the switch and counts that change instead of polling for it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi there,
I have a VB based application (.exe) and when you choose to close the application, one window pops up and ask if you really want to close the application, with Yes/No options, My question is how can I add a code to ask for a hard coded pass word if we want to close the application. So that the user would need to add a password to actualy being able to close it.
I have this part in my app.:
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Are you sure you want to Exit DCS?", vbYesNo + vbQuestion, "DSC (Data Car Server)") = vbNo Then
Cancel = True
End If
End Sub
Thanks,
|
|
|
|
|
It depends on how fancy you want to get, you could use in inputbox, I usually write my own form for passwords as teh injput box does not look real pretty....
|
|
|
|
|
I don't think VB has any password Dialog Forms pre made so you would have to build a new form with a password box and pop it up when the unload event is raised. Then you can check the password with the hardcoded one.
Kevin
|
|
|
|
|
i know this is vb forum but i am really struggling with this subject and i tihnk this is probably the best forum i know of to get advice.
Types of actual and formal var parameters must be identical
this error message is appearing when i call a function within another function.
Does any one know what would cause this?
And also i and getting an Incompatible types: 'String' and 'Integer'
for an integer but i have declared both the variables as ints and i am jsut passing one into the other,
i would really appreciate any help and if anyone would like me to be more specific jsut ask.
Thanks nicci.
-- modified at 16:34 Monday 27th November, 2006
to err is to be human but to really foul things up you need a computer!
|
|
|
|
|
lil_nicci wrote: Does any one know what would cause this?
Because you are not using a value that has the same type as the parameter, or can not be automatically converted to that type.
lil_nicci wrote: And also i and getting an for an integer
What?
---
b { font-weight: normal; }
|
|
|
|
|
sorry that was a bit soft off me i comment out the error messages.
this is the function i have:
procedure TfrmStandardConversion.SplitPND1D2D3(const suppnco: String;
out D1S, D2S, D3S: Integer; out suppnc: String; out ErrorCode: Integer);
var
D1A, D2A, D3A: Integer;
supp_pnA: String;
begin
ErrorCode:=0;
//First we need to see if the var we are passed IS 19 long.
if (Length(suppnco)=19) then
begin
supp_pnA := StringReplace(Copy(suppnco, 1, 6), ' ', '', [rfReplaceAll, rfIgnoreCase]);
if (Length(supp_pnA) <> 6) then
ErrorCode:=3;
if (Length(StringReplace(Copy(suppnco, 9, 3), ' ', '', [rfReplaceAll, rfIgnoreCase])) = 0) then
ErrorCode:=4;
if (Length(StringReplace(Copy(suppnco, 13, 3), ' ', '', [rfReplaceAll, rfIgnoreCase])) = 0) then
ErrorCode:=4;
if (Length(StringReplace(Copy(suppnco, 17, 3), ' ', '', [rfReplaceAll, rfIgnoreCase])) = 0) then
ErrorCode:=4;
try
D1A := StrToInt(Copy(suppnco, 9, 3));
except
on Exception : EConvertError do
ErrorCode:=2;
end;
try
D2A := StrToInt(Copy(suppnco, 13, 3));
except
on Exception : EConvertError do
ErrorCode:=2;
end;
try
D3A := StrToInt(Copy(suppnco, 17, 3));
except
on Exception : EConvertError do
ErrorCode:=2;
end;
if (ErrorCode = 0) then
begin
suppnc := supp_pnA;
D1S := D1A;
D2S := D2A;
D3S := D3A;
end;
end else
ErrorCode:=1;
end;
and i want to extract the three D1S, D2S, D3S and suppnc
and i think i an getting stuck because of the contents of the parameters when i have called the function. do you know what i should put.
thank you btw!
to err is to be human but to really foul things up you need a computer!
|
|
|
|
|
How do you call the method?
---
b { font-weight: normal; }
|
|
|
|
|
I am trying to empty partnumber columns in sql database that have all zeroes so that the column will be blank. I am writing code through vb.net. Here is some code that I am using but it doesn't work:
Function:
Public Function Empty(ByVal supercedeto As String) As Boolean
Dim number As String
number = String.Empty(supercedeto)
End Function
Code:
If row("mostforwardpartnumber").ToString() = "0000000000000" Then
Empty(row("mostforwardpartnumber"))
End If
jds1207
|
|
|
|
|
Hi,
The function as you posted it here, does not return anything, nor does it affect anything outside itself.
jds1207 wrote: Public Function Empty(ByVal supercedeto As String) As Boolean
Dim number As String
number = String.Empty(supercedeto)
End Function
Does the column contain a set or random amount of zeroes?
jds1207 wrote: If row("mostforwardpartnumber").ToString() = "0000000000000" Then
Empty(row("mostforwardpartnumber"))
End If
If the amount of zeroes is always the same, you don't need a function to empty the row. Try something like this:
<br />
Dim EmptyNr as integer<br />
Dim rw as datarow<br />
For Each rw In YourDataSet.Tables(0).rows<br />
If rw.item("mostforwardpartnumber") = "0000000000000" Then<br />
rw.item("mostforwardpartnumber") = EmptyNr<br />
End If
Otherwise you'll need to write a function that checks the value of the column and based on what that function returns, you can then empty the cel.
Hope this helps you,
Johan
|
|
|
|
|
being new to VB.NET, how do you programmatically select a datagrid cell
silver-gray
|
|
|
|
|
Give This a try
<br />
Datagrid1.CurrentCell = new Windows.Forms.DatagridCell(row, col)<br />
Kevin
|
|
|
|
|
what I'm trying to do is programmatically select all cells in the 4th column that comtain nulls, and change the backcolor to red. I have vb.net 2003.
silver-gray
|
|
|
|
|
how to well write the below statement :
I got into the msgbox(ii) even the value of the called function
[getavailableswitch(checkStr)] is 0
Dim ii As Integer <br />
If ii = getavailableswitch(checkStr) <> 0 Then<br />
MsgBox(ii)<br />
End If
Note : i want the the following to be done within the same if
1-call the function
2-test the retrieved data from the function
Am i thinking correctly???
Regards
Ramy
|
|
|
|
|
i found that this statement goes right
ElseIf (i = getavailableswitch(checkStr)) And i <> 0 Then<br />
MsgBox(i)<br />
End If
i got my respone
thx anyway :
but is there any other way of thinkin?
Regards
Ramy
|
|
|
|
|
What type value does your function return?
Your function should return as an integer or else you would need to convert to an integer to test the return value
i.e.
function getavailableswitch(checkstr as string) as integer
return 1
end function
If Not getavailableswitch(checkStr) = 0 then
or
If getavailableswitch(checkStr) <> 0 then
or
if CInt(getavailableswitch(Checkstr)) <> 0 then
Moo
|
|
|
|