|
Hi,
I suggest you try it. And look it up on MSDN. Or read a book on VB.NET
In fact the combination of these is the best way to make real progress.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
How can I make a Column on DataGridView accept only Numbers .. like Phone or price field >>>
jooooo
|
|
|
|
|
Hi jooooo
In design mode, select your data grid, select Edit Column from proeprtys, select your column from left panel and from right side options, select DataGridViewCellStyle prperty. Click on .. btn. In format, select Numeric for phone number with Decimal 0 and for price you can go for Numeric or Currency fomrat also. After setting this, if user enters anything else, Datagrid will throw exception and not allow user to input anything else.
Hope this helps the best
Thanks
Terry
|
|
|
|
|
Thanks Terry..
I did it ... but it's stell accepting non numeric keys and didn't make any exception ....
Many thanks for this Forum and all developers here ...
jooooo
|
|
|
|
|
I need some advice on how to handle semi global variable. I have had this issue before but currently its with a tracesource. I currently have a tracesource for each command I am creating in a toolbar. This way I can tell which command is giving me trouble. However I created a module called utilities that contains many subs and functions that I use between all of them. How do I set the values for this tracesource? The commands all have a oncreate sub that I use for the others so they are only class level. I can create the tracesource on the initialization of the toolbar but then its a global variable right? I am going to probably have this problem on several variable or objects so I would like to do this the best way.
Thanks
BlizzardIce
|
|
|
|
|
What is a 'semi global' variable ? I've never heard of such a thing.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thats a word I made up. The variable is a tracesource for the module. But I am not sure how or when to set its value. If this is the tracesource of the form I set it on the form create event. But my module has no create event. So when I can a sub or function in my module my trace statements will fail because the tracesource has not been defined. I don't really want to make a global variable and set it at the start of the program because I only need it if that module is going to be used. Does this make any more sense?
Blizzardice
|
|
|
|
|
I need a small help with a piece of code in VB.NET, that I am not getting right. I am trying to compare two directories, that have subdirectories containing files. I will have to compare both the directories and find out which subdirectories are the same (subdirectories having same files) and which subdirectories are different.
The code works fine till it gets into the respective two main directories and fetches the subdirectories present in them and also the files present in each of those subdirectories.
The problem I am facing is that the looping seems to be incorrect, which I am unable to debug. It doesn't compare all the subdirectories I think I am not getting the logic to proceed furthur. It breaks after one subdirectory. I will be very grateful, if anyone of you can assit me with the logic.
The code I have written is as below.
Dim file1byte As Integer
Dim file2byte As Integer
Dim fs1 As FileStream
Dim fs2 As FileStream
Dim path1 As String = mats.GetSetting("UnpackLocation") 'Directory 1 location
Dim getdir1 As String() = Directory.GetDirectories(path1)
Dim diren1 As System.Collections.IEnumerator
diren1 = getdir1.GetEnumerator
diren1.MoveNext() 'Points to the first subdirectory of Directory 1
Dim path2 As String = mats.GetSetting("path2") 'Directory 2 location
Dim getdir2 As String() = Directory.GetDirectories(path2)
Dim diren2 As System.Collections.IEnumerator
diren2 = getdir2.GetEnumerator
diren2.MoveNext() 'Points to the first subdirectory of Directory 2
Dim dirUpack1 As String() = Directory.GetFiles(diren1.Current) 'Gets the Files from the first subdirectory of Directory 1
Dim en1 As System.Collections.IEnumerator
en1 = dirUpack1.GetEnumerator
en1.MoveNext() 'Points to the first file in the subdirectory
Dim dirUpack2 As String() = Directory.GetFiles(diren2.Current) 'Gets the Files from the first subdirectory of Directory 2
Dim en2 As System.Collections.IEnumerator
en2 = dirUpack2.GetEnumerator
en2.MoveNext() 'Points to the first file in the subdirectory
Do
diren2.Reset()
diren2.MoveNext()
Do
en1.Reset()
en1.MoveNext()
Do
en2.Reset()
en2.MoveNext()
Do
' Determine if the same file was referenced two times.
If (en1.Current.ToString() = en2.Current.ToString()) Then
mats.ResultsLog.WriteError("Same File has been referenced Again!")
Exit Sub
End If
' Open the two files.
Console.WriteLine(en1.Current.ToString())
Console.WriteLine(en2.Current.ToString())
fs1 = New FileStream(en1.Current.ToString(), FileMode.Open)
fs2 = New FileStream(en2.Current.ToString(), FileMode.Open)
' Check the file sizes. If they are not the same, the files
' are not equal.
If (fs1.Length = fs2.Length) Then
Do
' Read one byte from each file.
file1byte = fs1.ReadByte()
file2byte = fs2.ReadByte()
Loop While ((file1byte = file2byte) And (file1byte <> -1))
' Close the files.
fs1.Close()
fs2.Close()
If ((file1byte - file2byte) = 0) Then
Console.WriteLine("The files are Same.")
GoTo jump1
Else
Console.WriteLine("The files are not Same.")
End If
Else
fs1.Close()
fs2.Close()
Console.WriteLine("The files are not Same.")
End If
' Return the success of the comparison. "file1byte" is
' equal to "file2byte" at this point only if the files are
' the same.
Loop While en2.MoveNext() = True
jump1: Loop While en1.MoveNext() = True
Loop While diren2.MoveNext() = True
Loop While diren1.MoveNext() = True
We will have to see if all the files in both the subdirectories are same, and if they are the same then Print that the SUB-DIRECTORIES are also same.
-- modified at 16:10 Wednesday 8th August, 2007
|
|
|
|
|
can someone please look at the problem?
|
|
|
|
|
hey,
gave it a quick scan looks ok ish.
have you not considered doing something like (excuse Pseudo)
function checkDir(D1,D2) as boolean
for each File in D1
compare it with D2.File
if any not equal then return false
next
'now check subdirectories
for each Sub in D1
if checkDir(D1.Sub , D2.Sub) = false then ' Its not equal - pass it up
return false
End if
next
End function
start the function with an Answer = checkDir(StartDir1,StartDir2)
its recursion which you may or may not like but it seems simpler somehow.
HTH
Martin
life is a bowl of cherries
go on take a byte
|
|
|
|
|
Hello Martin.
Thank you so much for your help. I could build the code from the logic you have provided and that worked. So, I appreciate your concern.
Ravi.
|
|
|
|
|
your very welcome
Martin
life is a bowl of cherries
go on take a byte
|
|
|
|
|
I user Enter key to move from textbot to another ..
but when I press it ... system send Beep ...
can I prevent it from doing Beep ?
jooooo
|
|
|
|
|
on keypress ( isuggest putting the form's keyprievew on and using the form keypress):
If e.KeyChar = CChar(13) Then<br />
e.Handled = True<br />
Else<br />
MyBase.OnKeyPress(e)<br />
End If
If this disables enter also then just put your normal enter actions after e.handled = true .
|
|
|
|
|
it's good
thanks my fried . but there's a small edit on the last code
If e.KeyChar = CChar(ChrW(13)) Then<br />
e.Handled = True<br />
Else<br />
MyBase.OnKeyPress(e)<br />
End If<br />
jooooo
|
|
|
|
|
Hello all,
Heard some great stuff about the code project so I decided to join the community and hope to be able to help others in the future as well.
Not yet there though since i'm fairly new to vb.net
Anyway: I need to print PDF files that are on disk to a network printer.
I searched for some printing code on the net and found several similar approaches.
However printing only seems to work to local printers, not network printers.
Even on local printers it sometimes fails.
I used the following code:
Dim PD As New System.Drawing.Printing.PrintDocument
Dim DefPrint As String = PD.DefaultPageSettings.PrinterSettings.PrinterName PD.DefaultPageSettings.PrinterSettings.PrinterName = .PrinterNaam
Dim NP As New Process()
NP.StartInfo.FileName = "c:\test.pdf"
NP.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
NP.StartInfo.Verb = "Print"
NP.Start()
NP.WaitForExit(9000)
If Not NP.HasExited Then
NP.Kill()
End If
PD.DefaultPageSettings.PrinterSettings.PrinterName = DefPrint
any way to improve this piece of code ?
it launches the print command to acrobat, but maybe there is a better trick to do the printing.
How comes this doesn't work for network printers ?
Thanks in advance,
Nick
|
|
|
|
|
I am having a time trying to get my tabindex right on one of my forms.
I have about 40 controls mostly text boxes and combo boxes. THey are all grouped inside of groupboxes and for somereason the tabindex does not stop on the text boxes just the combo boxes.
Humble Programmer
|
|
|
|
|
the tab order includes those controls that have TabStop=true; and it does that
in order of increasing TabIndex.
If, while modifying TabIndex with Visual Designer, you create a conflict (say you reuse
a TabIndex value), Designer will adapt the other one silently. So you may want to check
them twice !
Also I am not sure how it works for nested controls (as in a GroupBox); I expect there
to be a "local" world of tab indices.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
there is a very handy tool in visual studio 2005 (I think it exist in 2003 too but not sure about that)
go to menu view and choose tab order
then you get to see the taborder for each control
if you want to set them just click the number on the control (you will have to click in the correct order)
it's a very easy way to set the taborder on a form
|
|
|
|
|
I actually found this same information at another forum but when I tried it I am still having the same troble. I am wondering if it may have something to do with the type of controls on the form for exampe textboxes and Combo Boxes.
Humble Programmer
|
|
|
|
|
normally it should effect the tab order
the only thing I can think of is that the controls ar disabled if that is the case the tab will not stop at those controls (but you probably knew that already)
perhaps checking the tabindex property will clear things up a bit (make sure no control has the same tabindex)
|
|
|
|
|
in Menu There is TabOrder option select that it will shows the current tab position of u r controls , u adjust the taborder position and finally execute the programme then only u r changes will be accepted. unless u execute the programme u r changes will not get effect
prabumj@gmail.com
|
|
|
|
|
Hello,
VS 2005 + SQL Server 2005
I have created a PDA application that uses typed datasets. It connects to a web service that is connected to a SQL DB.
The PDA will sometimes be used offline, and the user will add, update, and delete the data on the pda. When the user goes online, how can I make the data that has been updated on the PDA be in sync when the user connects to the SQL db?
There many people using the same database concurrently.
Many thanks for any suggestions,
Steve
|
|
|
|
|
You will have to write a method that checks every once and a while to see when the last sync was, and then sync again. You will probably have to create another table in your database that stores information about when different tables were last update or keep a history of the changes that have been made or something along those lines. If you can trust that the user will shut off the program before shutting of the PDA, you can do this sync check in the Load event of your first page. If you don't feel comfortable using that event, you could set up a timer control that runs every half hour or hour or whatever. Is this what you were asking?
|
|
|
|
|
Hi all,
I want to enter some ids (4 or 5) into a new address group in outlook express thru VB. Can anyone help me out..??
Thnx in advance.
The name is Sandeep
|
|
|
|