|
hi,
i open a form as showdialog as following to get input
If frmFindVehicle.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
txtNumber.Text = frmFindVehicle.ReturnNumber
End If
frmFindVehicle.Dispose()
and coding of Ok Dialog result button of form(frmFindVehicle) is following
If dgvModelList.SelectedRows.Count = 0 Then
mdChecking.Prompt("Please select Model from grid")
Exit Sub
ElseIf dgvModelList.SelectedRows(0).Cells(9).Value = Nothing Then
Exit Sub
End If
ReturnNumber = dgvModelList.SelectedRows(0).Cells(1).Value
my problem is that when ok button is pressed and No row is selected then form(frmFindVehicle) must be open and force user to select a row. In above case it simply prompt the message and return back to main form.
|
|
|
|
|
i'm assuming at design time your assigning the dialogresult.ok to the ok button. Don't do that. In the click events of the ok and cancel set the result there.
Ex:
private sub cmdOK_Click(sender as object, e as system.eventargs) handles cmdOK.click
.
.
.
'do your checking and get out if failed...
me.dialogresult = windows.forms.dialogresult.ok
close
end sub
'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
|
|
|
|
|
Thanks , its work.
Also nice quote which is in bottom part of your message
|
|
|
|
|
Hi,
alternatively you could perform the checks in the FormClosing event, setting
FormClosingEventArgs.Cancel if necessary; and possibly reading FormClosingEventArgs.CloseReason
|
|
|
|
|
Also check that your form does not have an accept button assigned (caters for enter being pressed on the form, cancel suports esc) as this will automatically do the dialog result assignment.
I have been in the position of having to delete a button that has been assigned to the AcceptButton on a form and recreate it with a different name to get rid of the assignment. Therefore I have a mix of btnSave and btnOk in my apps - very irritating.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Structure of my application is:
1. Message is dispatched to an application
2. That application puts the message in a private queue
3. Another application reads messages from this queue and then calculates the receivers (pager) for this message and then puts single message to different private queues based on receiver types (pager carriers)
4. In the end different receiver console applications are set using MSMQ Triggers such that whenever a message arrives in the private queue particular receiver console application is fired
Now this seems to run smoothly but after running for some time the messages seem to get stuck in the receiving private queues on which triggers are set
Now the problem could be in:
- receiving application that stalls due to large number of messages in peak time
or
- msmq trigger service working that stops firing those applications and the private queue starts building up
One thing to note is that when this situation occurs then starting the MSMQ Trigger Service solves the issue and stuck messages in the queue starts going.
I am using:
Windows Server 2000
MSMQ 2.0
MSMQ Trigger Services 1.0
.NET 1.1 (console applications)
Could someone help me out in this?
|
|
|
|
|
hi all,
i simply pick a image from FileBrowserDialog and assign it to Picturebox as following
Dim a As New OpenFileDialog
a.Filter = "BMP Files" & Space(5) & "(*.bmp)|*.bmp|Jpg Files" & Space(5) & " (*.jpg)|*.jpeg"
If a.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = Image.FromFile(a.FileName)
MsgBox(PictureBox1.Image.Size.ToString)
End If
after assigning, i check image size which is in Pixcel. Now i want to check that whether the Width and Height of image(which is in Pixel), is less than the size 6 3/8" x 2 3/8" (which is in centimeters). So how can i change the image size to centimeter and compare them?
|
|
|
|
|
Well, you want it in centimeters relative to what ? A given resolution will result in a different size image based on the size of the screen.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hello
I'm writting a custom exception class and I want to have functionality to go to line number where the error occured. The code below should work but it fails at first line(giving com exception)
Dim DTE As EnvDTE.DTE = System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.9.0")
Dim item As EnvDTE.ProjectItem = DTE.Solution.FindProjectItem(FileName)
item.Open(EnvDTE.Constants.vsViewKindCode).Activate()
Dim textSelection As EnvDTE.TextSelection = DTE.ActiveDocument.Selection
textSelection.StartOfDocument()
textSelection.MoveToLineAndOffset(LineNumber, ColumnNumber)
textSelection.SelectLine()
I found a sample(in C#) where the GetService function was called and I cannot find it in VB.NET. The IServiceProvider interface provides one but I cannot find object that implements it.
Thanks in advance for help
|
|
|
|
|
The DTE stuff is usually only used in macros, not normal application programming. Even if this were to work, it would require every user of the resulting application to have Visual Studio installed.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Yes they would need a refernece to the dlls.
And I have found the solution
Dim DTE2 As EnvDTE80.DTE2
DTE2 = System.Runtime.InteropServices.Marshal. _
GetActiveObject("VisualStudio.DTE.9.0")
This will find instance of VS 2008
|
|
|
|
|
Pawel Gielmuda wrote: Yes they would need a refernece to the dlls.
Right, and I don't believe those DLLs are redistributable outside of Visual Studio so they would need to have Visual Studio installed.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
hi, im using VS2008 and working on windows form application,
i have a problem, is it can i take variable value from other form to another one form, or variable value from same form but different event.
for example:
pivate sub button1_click(byval........
dim one as string
one = "Hello"
end sub
then, i want take the value from variable 'one' and use it on another button click event
for example:
private sub button2_click(byval....
'here is the problem about how can i take
'the value in variable 'one' at button1_click event to be use in
'this event
end sub
|
|
|
|
|
|
try this.....................
dim one as string
pivate sub button1_click(byval........
one = "Hello"
end sub
then, if i want take the value from variable 'one' and use it on another button click event
for example:
private sub button2_click(byval....
msgbox (one)
end sub
|
|
|
|
|
If i understood your post right then
First declare the the variable globaly and public on form first not in any procedure
Public one as string
then on second form
dim frm as form1
msgbox(frm.one.tostring) ' u can use it any event of form2
Hope it will help u
Unless u don't give ur hundred percent whatever u r doning till there is no result of ur work...
|
|
|
|
|
The best way to do this is to create a delegate that passes the value between forms. Or use a property ( NOT just a variable ) that allows you to get ( but not set ) the value if the second form is a child of the first.
As for within the one form, place the variable at application scope. And, if you don't know that, you really need to buy a beginner book instead of relying on online help only.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
1. How to connect to Pocket PC(Windows Mobile) from Desktop PC?
2. if i connected to Pocket PC. How to get SMS from Pocket PC?
Thank U
|
|
|
|
|
Hi
For connect pocket pc with Desktop pC you need Data Cable and Active Sync Software.
after this you access every one from your window mobile like your desktop pc,
Thanx
~Khatri Mitesh
|
|
|
|
|
No No. I mean develop a software on desktop pc for connect to PocketPC.
|
|
|
|
|
Thank u. But i mean for coding with VB.Net.
|
|
|
|
|
|
i am using Using the MSScript control in win application.but i getting
error:-"The operation could not be completed because the script engine has not been initialized to a valid language."
Code:-
Dim MS As New MSScriptControl.ScriptControl
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
TextBox1.Text = MS.Eval(TextBox1.Text)
Catch ex As Exception
End Try
End Sub
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
AnsWer:-
Dim MS As New MSScriptControl.ScriptControl
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
MS.Language = "VBScript"
TextBox1.Text = MS.Eval(TextBox1.Text)
Catch ex As Exception
End Try
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
Hello all,
I'm using VB.NET(VS2003) connect with MySQL5.0 database. I'm trying to migrate the previous system which is using VB6 to VB.NET here.I am not familiar with VB6 code and I found this problem below:
Public Function CSQLQuote(ByVal Value As String) As String
' Value = Replace(Value, "\", "\\")
' CSQLQuote = Replace(Value, "'", "''")
CSQLQuote = mysql_escape_string(Value)
End Function
'API DECLARATION FOR mysql_escape_string FUNCTION CALL
Public Declare Function api_mysql_escape_string Lib "libmySQL.dll" _
Alias "mysql_escape_string" _
(ByVal strTo As String, _
ByVal strFrom As String, _
ByVal lngLength As Long _
) As Long
Public Function mysql_escape_string(dirtystring As String) As String
Dim strFrom As String 'SOURCE STRING PASSED TO FUNCTION
Dim lngFromLength As String 'LENGTH OF SOURCE STRING
Dim strTo As String 'DESTINATION STRING COMING FROM FUNCTION
Dim lngToLength As Long 'LENGTH OF DESTINATION STRING
strFrom = dirtystring 'STORE FUNCTION INPUT
lngFromLength = Len(strFrom) 'GET LENGTH OF INPUT
strTo = Space(lngFromLength * 2 + 1) 'ALLOCATE A BUFFER FOR OUTPUT OF FUNCTION
'2 BYTES PER CHARACTER PLUS A BYTE FOR NULL
'TERMINATOR USED BY FUNCTION
lngToLength = api_mysql_escape_string(strTo, strFrom, lngFromLength) 'CALL API
mysql_escape_string = Left(strTo, lngToLength) 'TRIM NULL TERMINATOR
End Function
These function will be called inside the SQL query like this:
strSQL = "SELECT LocationCode, TerminalCode, Source, Prefix, LastNo, Length" & _
" FROM POS_RunningNo" & _
" WHERE LocationCode='" & CSQLQuote(strLocationCode) & "'" & _
" AND TerminalCode ='" & CSQLQuote(strTerminalCode) & "'" & _
" AND Source='" & CSQLQuote(strSource) & "'"
I'm wondering I still need to used the above function apply on my new VB.NET system or I can just directly used the normal SQL query? And anyone can tell me whats the function above trying to do?
Hope someone can give me some ideas about it.Thanks for reading.
Regards
Drex
|
|
|
|