|
Once again, solved my own problem( that I created anyway. lol). I had an icon, that i had created, the icon contained support for 256x256 pixel vista icons, yet vs can't compile these so it spat this error. I edited my icon now all is fine.
Now for the question:
What do you suggest as the best method to validate text feilds on a form? The controls are databound(SQL). Would it be best to use masked textboxes or string validation? What is the best way to do string validation? Are there other ways to validate that are simpler and more effective?
OK 4 questions (I got carried away. lol)
Posted by The ANZAC
|
|
|
|
|
If you want to validate the length of input, just set the "MaxLength" property of the texbox to something.
If you want the field to be required, user a <asp:RequiredFieldValidator>
If you want the text box to be a specific set of numbers or date. Study and use the <asp:CompareValidator>
If you want to do anything funky, check out the <asp:RegularExpressionValidator>
(checkout http://regexlib.com/DisplayPatterns.aspx)
For each Validator, if you set the "Display" property to Dynamic, then the text in the "Text" property will be displayed NEXT to the textbox control. if the "Display" property is set to None, there will be no display to the error message. The advantage in that one is that you can place a <asp:ValidationSummary> control which will display all error messages in one block from ALL the validation controls.
Play around with these things. It's quite fun
|
|
|
|
|
This all sounds interesting, but i'm writing a windows application. Is it still applicable.
Posted by The ANZAC
|
|
|
|
|
Not sure mate.. sorry. I am programming a web application
|
|
|
|
|
Simply define what the user can and can't put in.
Use this in the forms keydown (make sure keypreview is enabled) to determine if it's a number or a letter:
<br />
Alpha = False<br />
<br />
If e.KeyCode < Keys.D0 OrElse e.KeyCode > Keys.D9 Then<br />
If e.KeyCode < Keys.NumPad0 OrElse e.KeyCode > Keys.NumPad9 Then<br />
Alpha = True<br />
End If<br />
End If<br />
If e.KeyCode = Keys.Back Then<br />
AllowBack = True<br />
Else<br />
AllowBack = False<br />
End If
Then use this in the field's keypress if you only want letters and other characters:
If Alpha = True Then<br />
e.Handled = False<br />
Else<br />
e.Handled = True<br />
End If
And use this in the field's keypress if you only want numbers and not other characters:
If Alpha = True Then<br />
e.Handled = True<br />
Else<br />
e.Handled = False<br />
End If<br />
If AllowBack = True Then<br />
e.Handled = False<br />
End If
-- modified at 0:13 Saturday 9th December, 2006
Posted by The ANZAC
|
|
|
|
|
Hello,
I have a checked list box. When I run the application the checked is populated. But when I click on one of the items in the list, I have to check it twice to check the item.
Is there anyway that I can do to just single click to check an item in the list.
Many thanks in advance,
Steve
|
|
|
|
|
Got it, Should have seen that.
clickOnCheck is the answer.
Steve
-- modified at 1:23 Friday 8th December, 2006
|
|
|
|
|
I am trying to get information on creating a virtual printer driver in vb.net.
Basically, I need the application to appear as a printer in the windows print dialog. When a text file is "printed" to this program, I have custom logic to parse the text file.
Any help is appreciated!
|
|
|
|
|
I need to seacrh a simple customer database. As the user types in letters to a textbox, the a listbox filled with all available options will highlight the closest option to what is being typed.
e.g. in textbox "j" is typed
Listbox highlights "jim"
When "jo" is typed the list should highlight john
How would i search the database (sql) for the closest match on the text_changed event
I am using Visual studio 2005, a dataset, binding source and table adapter.
P.S. Would it be possible to search a list box in the same method without actually searching the source.
Posted by The ANZAC
|
|
|
|
|
You can filter the listbox by iterating over methods and using the string.Contains method.
select * from blah were col LIKE @param + '%'
will find all strings that start with @param.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanx Christian, i found an easier way though...FindString, this searches the listbox as the user types, as this changes, the listbox highlights the most relevant item, and because all my controls are databound to the same source, this then displays the correct information in the other fields i have.
Dim i As Integer = Me.lstLast.FindString(Me.txtSearchLast.Text)<br />
Me.lstLast.SelectedIndex = i
Posted by The ANZAC
|
|
|
|
|
How do i reset 1st item for combolist VSFlexGrid to blank after load the data from database, eg:
If adoRset.RecordCount > 0 Then<br />
grdPeriods.ColComboList(grdPeriods.colIndex("VintageID")) = grdPeriods.BuildComboList(adoRset, "VintageCode", "VintageID")<br />
End If
Thanks
Angela
|
|
|
|
|
This script works great on the XP box I wrote it on but not on a Win 2000 box.
The script was found while Googling and I have added the rename sub and a few other changes to suite my required task.
I am reletivly new to dev and am not sure if the problem is win2k supporting the script or if the script needs changing.
The problem is at line 70 creating the tcp ip ports. if I take this out the script runs to completion telling me the printers are added but they are not.
I manually added the ports and re ran the script but no luck.
Please help...
<br />
'This script will add ip ports for your local printers and attach printers to<br />
'those ports. Just edit the arrays to reflect the paths for the .INF files<br />
'and get the printer descriptions from the .INF files. If the printer is listed<br />
'in the system32/inf/ntprint.inf use that as the .INF it tells the script where<br />
'to look for the driver otherwise use the UNC path to get the path.<br />
'===================================================<br />
strComputer = "."<br />
'strComputer can be an array of netbios computer names or<br />
'ip addresses put into a for loop<br />
'===================================================<br />
<br />
Public Error<br />
Dim Count:Count=0<br />
Set WshShell = WScript.CreateObject("WScript.Shell")<br />
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")<br />
<br />
<br />
Wscript.echo "This process may take several minutes please be patient." & VbCrLf _<br />
& "Another pop-up box will inform you when it is finished."<br />
<br />
'Here is where your edit the port IP addresses<br />
'===================================================<br />
Dim IPArray<br />
IPArray = Array( "192.168.100.1","192.168.100.1")<br />
Dim PrintersArray<br />
'===================================================<br />
<br />
'Here is where you enter the driver inf paths<br />
PrintersArray=Array("C:\CanonDrivers\win2k_xp_PCLModBW\P52KUKAL.INF",_<br />
"C:\CanonDrivers\win2k_xp_PS_2-9\W2KPS3K.INF")<br />
'===================================================<br />
<br />
'Here is where you edit the printer names<br />
Dim PrinterNames<br />
PrinterNames=Array("Canon iR C5180 PCL5c", "Canon iR C5180 PS3")<br />
'===================================================<br />
<br />
'Here is where you edit the new printer names<br />
Dim PrinterNewNames<br />
PrinterNewNames=Array("Black and White", "Colour")<br />
'===================================================<br />
<br />
For n = LBound(IPArray) To UBound(IPArray)<br />
'Install the IP printer ports<br />
Install_IP_Ports IPArray(n)<br />
Next<br />
For n = LBound(IPArray) To UBound(IPArray)<br />
Count = Count + 1 'just increments the counter for the message at the end!<br />
'===================================================<br />
<br />
'Add the printers (Arguments: ip port, path to the .inf files, printer name)<br />
'get the name from the inf files or make one up!<br />
'===================================================<br />
<br />
Add_local_ip_printer IPArray(n), PrintersArray(n),PrinterNames(n)<br />
Next<br />
'===================================================<br />
<br />
'If only one printer in array set to zero e.g. PrinterNames(0) or comment out!=<br />
Make_Default_printer PrinterNewNames(0)<br />
<br />
'===================================================<br />
'Install the TCP/IP Port(s):<br />
Function Install_IP_Ports(strIPAddress)<br />
<br />
Set objWMIService = GetObject("Winmgmts:")<br />
objWMIService.Security_.Privileges. _<br />
AddAsString "SeLoadDriverPrivilege", True<br />
<br />
Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_<br />
objNewPort.Name = strIPAddress<br />
objNewPort.Protocol = 2<br />
objNewPort.HostAddress = strIPAddress<br />
objNewPort.PortNumber = "515"<br />
objNewPort.Queue = "lp"<br />
objNewPort.SNMPCommunity = "public"<br />
objNewPort.SNMPEnabled = False<br />
objNewPort.Put_<br />
<br />
'stop the spooler<br />
Set colServiceList = objWMIService.ExecQuery _<br />
("Select * from Win32_Service where Name='Spooler'")<br />
For Each objService In colServiceList <br />
errReturn = objService.StopService()<br />
WScript.Sleep 1000<br />
Next<br />
<br />
'start the spooler<br />
For Each objService In colServiceList<br />
errReturn = objService.StartService()<br />
WScript.Sleep 5000<br />
Next<br />
<br />
End Function<br />
<br />
Function Add_local_ip_printer(strIP,strPath_To_Inf_Files,strPrintername)<br />
<br />
WSHShell.run ("CMD.EXE /C RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "_<br />
& chr(34) & strPrinterName & chr(34) & " /f " & chr(34) _<br />
& strPath_To_Inf_Files & chr(34) & " /r " & chr(34) _<br />
& strIP & chr(34) & " /m " & chr(34) & strPrinterName & chr(34) _<br />
& " /q /u"),0,True<br />
<br />
ReNamePrinter strPrintername,PrinterNewNames(n)<br />
<br />
End Function<br />
<br />
Function ReNamePrinter(prnName,prnNewName)<br />
<br />
Set objWMIService = GetObject("winmgmts:" _<br />
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")<br />
<br />
Set colPrinters = objWMIService.ExecQuery _<br />
("Select * from Win32_Printer Where DeviceID = '" & prnName & "'" )<br />
<br />
For Each objPrinter in colPrinters<br />
objPrinter.RenamePrinter(prnNewName)<br />
'objPrinter.Put_<br />
Next<br />
<br />
End Function<br />
<br />
Function Make_Default_printer(strPrinterName)<br />
<br />
Set colInstalledPrinters = objWMIService.ExecQuery _<br />
("Select * from Win32_Printer") <br />
For Each objPrinter in colInstalledPrinters<br />
If objPrinter.Name = strPrinterName Then<br />
objPrinter.SetDefaultPrinter()<br />
End If<br />
Next<br />
<br />
End Function<br />
<br />
Wscript.echo "Install completed, please check you have 2 printers added" & VbCrLf _<br />
& "One named 'Black and White' and the other named 'Colour'"<br />
'End Script<br />
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
Hi,
I need to round the minutes to the nearest queater of hour. For example if it is 00:07 (hour:minutes) then it would be 00:15, if 00:05 then it would be 00:00.
Any ideas how to go about doing this?
Many thanks for your time.
|
|
|
|
|
you can use an if elseif then statement to accomplish this task or even a select case. Are you pulling the time from the Now function and if so then you will need another var to hold the rounded time value.
Recreating the wheel is the best way to appreciate what the previous coders have gone through to get you where you are now.
|
|
|
|
|
Here is an example of what I was talking about using the if elseif then statement. This assumes you have two labels on a form named Label2 and Label3.
Private Sub Load_Time()
'calculates the rounded time
Dim newtime As DateTime
Dim min As Integer = Now.Minute
Label2.Text = Now.ToShortTimeString
If min >= 0 And min <= 15 Then 'First Quarter
If min > 7 Then
'move up
newtime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, 15, Now.Second)
Label3.Text = newtime.ToShortTimeString
Else
'move down
newtime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, 0, Now.Second)
Label3.Text = newtime.ToShortTimeString
End If
ElseIf min > 15 And min <= 30 Then 'Second Quarter
If min > 22 Then
'move up
newtime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, 30, Now.Second)
Label3.Text = newtime.ToShortTimeString
Else
'move down
newtime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, 15, Now.Second)
Label3.Text = newtime.ToShortTimeString
End If
ElseIf min > 30 And min <= 45 Then 'Third Quarter
If min > 37 Then
'move up
newtime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, 45, Now.Second)
Label3.Text = newtime.ToShortTimeString
Else
'move down
newtime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, 30, Now.Second)
Label3.Text = newtime.ToShortTimeString
End If
ElseIf min > 45 And min <= 59 Then 'Fourth Quarter
If min > 52 Then
'move up
newtime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour + 1, 0, 0)
Label3.Text = newtime.ToShortTimeString
Else
'move down
newtime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, 45, Now.Second)
Label3.Text = newtime.ToShortTimeString
End If
End If
newtime = Nothing
min = Nothing
End Sub
Recreating the wheel is the best way to appreciate what the previous coders have gone through to get you where you are now.
|
|
|
|
|
Hi,
I have a VC++/MFC application.
I decided to move the UI to VB.NET to improve it.
I created a VB project with new interface and moved the C++ core into a MFC dll project.
When I run the application I got 'Stack owerflow' inside the MFC code.
For code details:
The C++ code does image processing using some recursive functionality, that is the point where the stack sucks up.
It happens when I passing over 4400 iterrations (the maximum is about 12000).
The recursive function looks like this
// Check for continous black areas
void CBitmapScan::CheckAround(CRect* pBound, int nX, int nY)
{
if(oMemDC.GetPixel(nX, nY) == RGB(0x00, 0x00, 0x00))
{
// Remove the pixel to avoid duble-check
oMemDC.SetPixel(nX, nY, RGB(0xff, 0xff, 0xff));
// Set new bounds
if(pBound->left > nX) pBound->left = nX;
if(pBound->right < nX) pBound->right = nX;
if(pBound->top > nY) pBound->top = nY;
if(pBound->bottom < nY) pBound->bottom = nY;
// Check up-down-left-right
CheckAround(pBound, nX + 1, nY);
CheckAround(pBound, nX - 1, nY);
CheckAround(pBound, nX, nY + 1);
CheckAround(pBound, nX, nY - 1);
}
}
Why this happening?!
Thanks in advance
Peter
|
|
|
|
|
I'm creating this asteroids-like game in vb for this vb class that I'm in and I need to be able to have multiple keys performing their functions at the same time. I am currently using the preview key down event for each of the keys but with that if you have one key pressed down and press another one it stops performing the operations of the first key. My professor said i needed something like asynchronous key detection but I couldn't find anything on it in the searches i did. Can anyone help me out?
|
|
|
|
|
You need to use DirectX for this. Direct Show is going to give you that sort of control over keys. The other option is to pinvoke GetAsyncKeyState or GetKeyState.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I feel like this should be an easy task, but I am having some issues.
I have a tab control, call it tabControl1, and 8 tabs, call them tabPage1 - 8. The length of the text on each tab is different. I want to create a 'justified' look and put the tabs in two rows (similar to MS Word tools>options).
I can adjust the padding, which changes the padding for all the tabs. But when I do this, the longer of the two rows appears to float.
If anyone could give me some guidance on this or point me in the right direction I would appreciate it.
Thanks in advance.
|
|
|
|
|
I converted VB.NET 1.1 Windows application to 2.0.
It's MDI application with many MDI children.
Now I got strange error. When few diffrent MDI children opened at the same time, and then you close one child , the whole MDI parent form falls into infinite loop like trying to redraw other child. And there is no other way to stop it, but close application using Ctrl+Alt+Delete. The funny thing is it happen not with all children forms, but I cannot find the rule or reason why.
Can someone help?
Thank you in advance.
|
|
|
|
|
trying again
dim frm as childform
Click_event...
frm =new childform
frm.mdiparent=me
frm.show
|
|
|
|
|
Thank you for the response.
That was exactly what I was doing. And I found the cause of this error. Most of the child forms have Maximized state and that what makes error.It looks like form starts draw and redraw header of the form and maximize it in a endless loop. As soon as I set it to Normal, the error gone. Instead on a Load event i resized the child form to Client area of MDI form and also removed maximized button. It solved the problem, but it is not how I expected make it. I have about 60!!! child forms and I need to open each one and change setting.
|
|
|
|
|
Hi everybody,
I found some code to hook, low-level, the keyboard and the mouse.
After some changes to get it working with vb 2005, I get the following error:
"CallbackOnCollectedDelegate was detected ....."
This is some of the code:
Private Function LowLevelKeyboardProc( _
ByVal nCode As Integer, _
ByVal wParam As Integer, _
ByVal lParam As KBDLLHOOKSTRUCT) As Integer
If (nCode = HC_ACTION) Then
If wParam = WM_KEYDOWN Or _
wParam = WM_SYSKEYDOWN Or _
wParam = WM_KEYUP Or _
wParam = WM_SYSKEYUP Then
Return 1
End If
Return CallNextHookEx(hhkLowLevelKybd, _
nCode, wParam, lParam)
End If
End Function
Private Delegate Function LowLevelKeyboardProcDelegate( _
ByVal nCode As Integer, _
ByVal wParam As Integer, _
ByVal lParam As KBDLLHOOKSTRUCT) As Integer
Public Sub EnableKeyboard()
UnhookWindowsHookEx(hhkLowLevelKybd)
End Sub
Public Sub HookKeyboard()
Dim callback = New LowLevelKeyboardProcDelegate(AddressOf LowLevelKeyboardProc)
KeyboardHandle = SetWindowsHookEx(WH_KEYBOARD_LL, _
AddressOf LowLevelKeyboardProc, Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
GC.KeepAlive(callback)
End Sub
Doe someone knows what is going wrong?
Thanks,
Jurgen
|
|
|
|
|
Hi all
I am developing a VB application in which I have created a translucent form using SetLayeredWindowAttributes API. On sharing of this application using netmeeting or windows messenger the client system is unable to view the application properly. Kindly suggest.
Thanks in advance
Regards
|
|
|
|
|