|
Hey guys, I'm making a program that creates a customized message box, but it keeps giving me an error. The "IconChoice" variable determines what icon shows up in the messagebox, the "ButtonChoice" variable determines what buttons will show up, and the "DefaultButton" variable determines which button is the default one. The txtMessage and txtTitle are the box's text and title. Here's the code:
<code> Dim IconChoice As String
Dim ButtonChoice As String
Dim DefaultButton As String
Private Sub radbtn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radbtn1.Click
raddef1.Enabled = True
raddef2.Enabled = True
raddef3.Enabled = True
raddef4.Enabled = False
raddef5.Enabled = False
raddef6.Enabled = False
raddef7.Enabled = False
ButtonChoice = "MessageBoxButtons.AbortRetryIgnore"
End Sub
Private Sub radbtn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radbtn2.Click
raddef1.Enabled = False
raddef2.Enabled = False
raddef3.Enabled = False
raddef4.Enabled = True
raddef5.Enabled = False
raddef6.Enabled = False
raddef7.Enabled = False
ButtonChoice = "MessageBoxButtons.OK"
End Sub
Private Sub radbtn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radbtn3.Click
raddef1.Enabled = False
raddef2.Enabled = False
raddef3.Enabled = False
raddef4.Enabled = True
raddef5.Enabled = True
raddef6.Enabled = False
raddef7.Enabled = False
ButtonChoice = "MessageBoxButtons.OKCancel"
End Sub
Private Sub radbtn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radbtn4.Click
raddef1.Enabled = False
raddef2.Enabled = True
raddef3.Enabled = False
raddef4.Enabled = False
raddef5.Enabled = True
raddef6.Enabled = False
raddef7.Enabled = False
ButtonChoice = "MessageBoxButtons.RetryCancel"
End Sub
Private Sub radbtn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radbtn5.Click
raddef1.Enabled = False
raddef2.Enabled = False
raddef3.Enabled = False
raddef4.Enabled = False
raddef5.Enabled = False
raddef6.Enabled = True
raddef7.Enabled = True
ButtonChoice = "MessageBoxButtons.YesNo"
End Sub
Private Sub radbtn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radbtn6.Click
raddef1.Enabled = False
raddef2.Enabled = False
raddef3.Enabled = False
raddef4.Enabled = False
raddef5.Enabled = True
raddef6.Enabled = True
raddef7.Enabled = True
ButtonChoice = "MessageBoxButtons.YesNoCancel"
End Sub
Private Sub radicon1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radicon1.Click
IconChoice = "MessageBoxIcon.Asterisk"
End Sub
Private Sub radicon2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radicon2.Click
IconChoice = "MessageBoxIcon.Error"
End Sub
Private Sub radicon3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radicon3.Click
IconChoice = "MessageBoxIcon.Exclamation"
End Sub
Private Sub radicon4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radicon4.Click
IconChoice = "MessageBoxIcon.Hand"
End Sub
Private Sub radicon5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radicon5.Click
IconChoice = "MessageBoxIcon.Information"
End Sub
Private Sub radicon6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radicon6.Click
IconChoice = "MessageBoxIcon.None"
End Sub
Private Sub radicon7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radicon7.Click
IconChoice = "MessageBoxIcon.Question"
End Sub
Private Sub radicon8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radicon8.Click
IconChoice = "MessageBoxIcon.Stop"
End Sub
Private Sub radicon9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radicon9.Click
IconChoice = "MessageBoxIcon.Warning"
End Sub
Private Sub raddef1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles raddef1.Click
DefaultButton = "MessageBoxDefaultButton.Button1"
End Sub
Private Sub raddef2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles raddef2.Click
If radbtn1.Checked Then
DefaultButton = "MessageBoxDefaultButton.Button2"
Else
DefaultButton = "MessageBoxDefaultButton.Button1"
End If
End Sub
Private Sub raddef3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles raddef3.Click
DefaultButton = "MessageBoxDefaultButton.Button3"
End Sub
Private Sub raddef4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles raddef4.Click
DefaultButton = "MessageBoxDefaultButton.Button1"
End Sub
Private Sub raddef5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles raddef5.Click
If radbtn6.Checked Then
DefaultButton = "MessageBoxDefaultButton.Button3"
Else
DefaultButton = "MessageBoxDefaultButton.Button2"
End If
End Sub
Private Sub raddef6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles raddef6.Click
DefaultButton = "MessageBoxDefaultButton.Button1"
End Sub
Private Sub raddef7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles raddef7.Click
DefaultButton = "MessageBoxDefaultButton.Button2"
End Sub
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
MessageBox.Show(""" & txtMessage.Text & """, """ & txtTitle.Text & """, ButtonChoice, IconChoice, DefaultButton)
End Sub</code>
|
|
|
|
|
You can't use string values as if they were enum values. Declare the variables as the proper enums instead:
Dim IconChoice As MessageBoxIcon<br />
Dim ButtonChoice As MessageBoxButtons<br />
Dim DefaultButton As MessageBoxDefaultButton
Now assign the variables the enum values instead of strings:
IconChoice = MessageBoxIcon.Stop<br />
ButtonChoice = MessageBoxButtons.YesNo<br />
DefaultButton = MessageBoxDefaultButton.Button3
Now the variable will work in you call to MessageBox.Show .
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi all !
I have a file Info.dat, Now i want to read content of this file( I know struct of this file). how can i do ? Thanks a lot. Please send to caoquanghanh@yahoo.com
example:
Type PutAd_File
TradeID As Integer
SecNo As Integer
vol As Long
price As Double
FirmNo As Long
Side As String * 1
Board As String * 1
Time As Long
Flag As String * 1
End Type
hanhquang
|
|
|
|
|
caoquanghanh wrote: Please send to caoquanghanh@yahoo.co
Expect answer in the forum, not to your email. This is not a billboard.
caoquanghanh wrote: I have a file Info.dat, Now i want to read content of this file( I know struct of this file). how can i do ?
You can use the BinaryReader class to read the data from the file.
---
single minded; short sighted; long gone;
|
|
|
|
|
I can't find BinaryReader class wijt VB code. Can you help me. thanks alot
hanhquang
|
|
|
|
|
System.IO.BinaryReader
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi All,
Can anybody tell me how to read the PDF file to get the data line by line without using any third party control.
Thanx in Advance
Max
|
|
|
|
|
I'm Subrahmanyam .I have a small problem in using list box.The problem is like this
i'm doing a windows applcation.
In this i have a textbox and a list box which contains list of items .
If i type 'c' or any letter in the text box then the cursor should
automatically go to
the word that starts with 'c' and that element should be the 1 st one
in the list .
i'm trying to do with findstring method but unable to do it.
so i request you to help me in this.
Thanking You Sir,
Regards,
Subrahmanyam.
|
|
|
|
|
Are you doing:
dim idx as int = listBox.FindString(textbox.text)
listBox.SelectedIndex = idx
???
You need to set the selectedIndex property in the ListBox.
Note if the idx value is -1 then it didn't find the string.
Hope that helps.
Ben
|
|
|
|
|
I am building an application in VB.BET and ADO.NET.
The application requires searching only. The searches are on wide varity of criteria and huge tables. The output resultsets may also be very big or small depending on the query.
The backend being used is Microsoft Access.
The search fields are usually indexed. Before switching over to ADO.NET, I was programming in VB6 and used SEEK which proved to be very fast. But I find no similar thing in ADO.NET.
So given that No add/update is required, only searching is required,
1. What is the best alternative to SEEK in ADO.NET?
2. Which data mining technique should suit better? - Dataset or datareader.
3. How can I optimize queries on Memo fields?
4. Tips for faster searching and best practices.
Thanks a lot in advance for those who reply. Even small hints would be very appreciated. Please do not hesitate to answer even if you are not very confident or you can help me with even one of the questions mentioned above.
|
|
|
|
|
Well, I will say I am in the not very confident catagory since it has been a long long time since I have used Access. I do a long of work in SQL with ado.net so it should be pretty similar.
I believe in ado.net you will have to use a command object. You pass in a select statement. Since you are doing searching I would always use the datareader, it is faster then a dataset.
Hope that helps.
Ben
|
|
|
|
|
Thanks a lot Ben.
So that confirms one of the questions I posted.
Anyone, any suggestions about the other?
Thanks,
|
|
|
|
|
I am not that familar with memo fields in access. So I don't know how to best handle them. As far as best practices. All tables should have primary keys. These primary keys in general should be used to link tables together. After you are pretty much done with the app, it is a good idea to go back over your queries and see if the under performing ones need additional indexs on those tables to speed them up. Sometimes it is hard to tell if there are only a few rows in the tables. You should be the most concerned with the tables that will get larger over time. It is never a bad idea to think through archiving old data. If you have a production system where after three months the data is pretty useless, them move it off to someplace else or flat out delete it.
Hope that helps.
Ben
|
|
|
|
|
My database is already having appropriate indexes and primary keys wherever suitable. The old application was built in VB6. I need to port my VB6 code to VB.NET.
My biggest concern still remains.
The classic ADO had the SEEK method that could utilize the indexes and get very fast results. I tried various ADO.NET methods, but nothing gets even near to the speed I was getting earlier. My application has bogged down and has raised a big concern.
I was wondering if there is any way in ADO.NET to utilize the indexes in database?
Please help.
|
|
|
|
|
Normally you would do this is the query itself. This is where I am not very certain what you can do in access. In sql you can just write the query. Select column1, column2, etc from table where column1 = 'fred'
If column1 is index that query is very fast. I am just not sure if you can do this. If you can it would be with a sqlCommand object. You would set the commandtext to the query and then call the executereader to return the result set.
Again my issues is I have never tried to do this with Access. I think it will work since access has a very similar sql engine, but I don't know exactly how.
Hope that helps.
Ben
|
|
|
|
|
I have been a classic ASP and Visual Basic 6.0 programmer for some time. My company went belly up and now I am unemployed. I want to stay in my home town.
All the jobs that are available all want 1-3 years of .NET experience. This is rediculious. Is it some kind of way to keep the old guys out of the market.
Come on, I use to program mail frame, and taught myself the PC area.
Does anyone know how to break thru the gate, get pass the palace guard? I have read a good number of books on the subject. Loaded up MS .NET Framework on my PC. And written a few programs/systems.
Anybody have any helpful suggestions>
Chuck
|
|
|
|
|
I passed through the same situation and can understand your grief.
Come to the ground situation and start believing that VB6 and ASP are history now.
Take my suggestion and get a good book on VB.NET and ASP.NET today itself and start working hard. Or take some good tution from some good institute. It would be hardly a matter of 3 to 6 months before you get back on to the track.
Good Luck
|
|
|
|
|
chuckd0138 wrote: All the jobs that are available all want 1-3 years of .NET experience. This is rediculious.
Welcome to the world of IT recruitment. It will always be this way. Consequently there will always be "skills shortages." (Though in this particular case companies can find plenty of people who meet this spec.)
chuckd0138 wrote: Is it some kind of way to keep the old guys out of the market.
To some extent. For example, occasionally you will see jobs advertised that are more relaxed in their skills requirements and perhaps offer cross-training. But the salaries will be low and/or they will be aimed at graduates with a few years' general commercial experience.
Basically, in this industry I've discovered that the older you get the more important it is to acquire commercial experience in the latest skills, whether you want to or not.
chuckd0138 wrote: Does anyone know how to break thru the gate, get pass the palace guard? I have read a good number of books on the subject. Loaded up MS .NET Framework on my PC. And written a few programs/systems.
Just keep on doing what you are doing. Also try applying it to a web site or something and then put it on your Resume. Eventually someone will give you a chance. I've been where you are (and I'm an "older guy" too) . It's frustrating but hang in there.
|
|
|
|
|
If you are really serious about getting into vb.net asp.net then I suggest you try to get some microsoft certification. Something like the MCAD.net or MCSD.net. The MCAD.net is for .net 1.1 and there are three required tests. The MCSD.net includes the 3 MCAD.net tests along with two addional tests. If you can achieve that certification, then you can go into a job interview and say hey I have the certification and I am building my experience.
NOTE these tests are not easy to pass and require a lot of study. The tests are cheap either $125 a test. Also the processes can be long it took me a good 6 or 7 months to pass all 5 tests.
NOTE there are newer certification for .net 2.0. I have found these tests to be even harder then the 1.1 tests.
Hope that helps.
Ben
|
|
|
|
|
How can i make trial version in vb.net?
................
|
|
|
|
|
Socheat.Net wrote: How can i make trial version in vb.net?
A bit vague...
Maybe a better approach will be:
"I have an application as follows [..], I would like to build a trial version that includes/escludes the following functionalities [...], the trial has/hasn't to expire after some time...."
BTW Google is often you best friend.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Pseudocode:
If now > expiration date
msgbox("Expired!")
me.close()
End If
Or, if you want to make it expire after X number of days, use my.settings...
'load event
if my.settings.CreateDate = Nothing then
my.settings.CreateDate = now
elseIf my.settings.CreateDate - now > X 'X being how long the trial period should last
msgbox("Expired!")
me.close()
else
'Your code here
end if
Don't use this exact code! It's not secure (so especially don't use it for anything important) and you should know how it works.
|
|
|
|
|
Thanks in advance
................
|
|
|
|
|
Hi! Give me please example for Response.Cache.SetETag(“????”)
Are other words, what string I have gone set to SetETag?
In order to return code 200 or 304.
-- modified at 7:27 Tuesday 3rd April, 2007
|
|
|
|
|
After a long time searching...
After so many mouse-click...
Surfed so many pages
I think it is ok to work as a global hook but it doesn't work.
I don't know where the problem is.
Here is my steps:
1.open a new windows aplication project.
2.add a module with code below
<br />
Module Module1<br />
Declare Function GetCurrentThreadId Lib "kernel32" Alias "GetCurrentThreadId" () As Integer<br />
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As HOOKPROC, ByVal hmod As Integer, ByVal dwThreadId As Integer) As Integer<br />
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Integer) As Integer<br />
Declare Function CallNextHookEx Lib "user32" Alias "callnexthookex" (ByVal hHook As Integer, ByVal ncode As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer<br />
<br />
Public Delegate Function HOOKPROC(ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer<br />
<br />
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer<br />
<br />
Public hnexthookproc As Integer = 0<br />
<br />
Public Const PM_KEY_PrintScreen = &H2c<br />
<br />
Public Structure KbStruct<br />
Dim vkCode As Integer<br />
Dim ScanCode As Integer<br />
Dim Flags As Integer<br />
Dim Time As Integer<br />
Dim dwExtraInfo As Integer<br />
End Structure<br />
<br />
Public Enum HookType<br />
<br />
WH_KEYBOARD = 2<br />
<br />
End Enum<br />
<br />
Public Sub UnHook() 'close Hook <br />
If hnexthookproc <> 0 Then<br />
UnhookWindowsHookEx(hnexthookproc)<br />
hnexthookproc = 0<br />
End If<br />
End Sub<br />
<br />
Public Function SetHook() 'set Hook <br />
If hnexthookproc <> 0 Then<br />
Exit Function<br />
End If<br />
<br />
hnexthookproc = SetWindowsHookEx(HookType.WH_KEYBOARD, AddressOf MyKeyboardProc, 0, GetCurrentThreadId())<br />
End Function<br />
<br />
<br />
Public Function MyKeyboardProc(ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer<br />
MyKeyboardProc = 0<br />
If nCode < 0 Then<br />
MyKeyboardProc = CallNextHookEx(hnexthookproc, nCode, wParam, lParam)<br />
Exit Function<br />
End If<br />
<br />
If wParam = PM_KEY_PrintScreen Then<br />
MyKeyboardProc = 1<br />
MsgBox("HOOK!")<br />
End If<br />
End Function<br />
End Module<br />
3.call my function to set hook in form_load and close in form_close:
<br />
Public Class Form1<br />
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Call SetHook()<br />
End Sub<br />
<br />
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed<br />
Call UnHook()<br />
End Sub<br />
<br />
End Class<br />
|
|
|
|