|
twsted f8 wrote: it works on one form but the same code copied and pasted does not work on a different form
What is not working? Be a little more descriptive.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi Paul
The code is meant to check all the text boxes on a form. If a blank field is found the user a msgbox is displayed asking the user to enter the required information. Similarly the code can also be used to check each text box to see if the data entered is of the correct type.
On the first form code identifies all the textboxes that have been left blank. On the 2nd form this same code does not work. When I click the button, nothing happens, the blank textboxes are not identified and no error messagebox is displayed, of which when I do the same thing on the first form the program is able to pick up all the blank fields.
|
|
|
|
|
Is this code being called in both forms ? Do you have breakpoints so you can see what is going on ?
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 )
|
|
|
|
|
Like Christian said, is it being called by both? Have you tied in any event procedures to call it?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
twsted f8 wrote: I am having problems with code that works when it suits it.
This is almost certainly not true.
Most likely, on one form you have an event set up to call this method, and on the other, you do not.
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 )
|
|
|
|
|
Hi,
Do you host your textboxes into sub-containers (e.g. Groupbox, Panel, ...) If yes, then you must iterate over the controls of sub-containers.
Hope this helps
|
|
|
|
|
Hi
Thanks for helping. I do have a group box on the form. I still got a bit of a qn? What do u mean by iterate over the controls of the form, How could I go about this?
Thanks again.
twsted f8
|
|
|
|
|
i check what u have written is also not working
what i will give u this is the correct coding
copy it
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is TextBox Then
ctrl.Text = ""
End If
Next
|
|
|
|
|
Hi
I am kinda new to vb.net and I am having problems with code that works when it suits it. The code is meant to check if data has been entered into the text boxes. For some unknown reason it works on one form but the same code copied and pasted does not work on a different form.
this the code.
'This checks the textboxes to see if the data entered is correct
Dim ctrlx As Control
For Each ctrlx In Controls
If TypeOf ctrlx Is TextBox Then
If ctrlx.Text = "" Then
ctrlx.Focus()
MessageBox.Show("Please enter the required data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
End If
Next
I hope u will be able to help me,
twsted f8
|
|
|
|
|
Don't post the same message twice.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
You cannot compare the type of control with TextBox Class. The control has to be compared with the type of TextBox.
Possibly the the code snippet will resolve your issue
For Each ctrl As Control In Me.Controls
If ctrl.GetType() Is GetType(TextBox) Then
If ctrl.Text="" Then
MessageBox.Show("Message",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
ctrl.Focus()
End IF
End If
Next
Santosh Metal
|
|
|
|
|
hello i am new in vb.net
and i am doing phone direcroty application, so in this application input is users name, middle name, surname,home phone,mobile,email,houseno, add,town,postcode,counrty etc and i have used all this as string variable
and code is like this
Option Explicit On <br />
Option Strict On<br />
Public Class frmPhone<br />
Inherits System.Windows.Forms.Form<br />
<br />
'Globle variables<br />
Dim FileNumber, Position As Integer, FileName As String<br />
Dim MyFile As String = "phonelist.txt"<br />
<br />
'create record type the name of record is PhoneList<br />
Structure PhoneList<br />
Dim Inits As String<br />
Dim Gender As String<br />
<VBFixedString(20)> Dim FName As String<br />
<VBFixedString(20)> Dim SName As String<br />
<VBFixedArray(2)> Dim MName As String<br />
<VBFixedArray(20)> Dim HomePhone As String<br />
<VBFixedArray(20)> Dim Mobile As String<br />
<VBFixedArray(30)> Dim Email As String<br />
<VBFixedArray(5)> Dim HouseNo As String<br />
<VBFixedArray(20)> Dim FLine As String<br />
<VBFixedArray(20)> Dim SLine As String<br />
<VBFixedArray(20)> Dim Town As String<br />
<VBFixedArray(10)> Dim PostCode As String<br />
<VBFixedArray(15)> Dim Country As String<br />
End Structure<br />
'Function to use last record<br />
Private Function FindLastRecordNo() As Integer<br />
Dim Temp As PhoneList, FileNum As Integer<br />
FileNum = FreeFile() 'Free file number<br />
FileOpen(FileNum, MyFile, OpenMode.Random, , , Len(Temp))<br />
FindLastRecordNo = 1<br />
Do While Not EOF(FileNum) 'EOF() function is using to detect the end of file<br />
Dim vt As ValueType = Temp<br />
FileGet(FileNum, vt, ) 'Get file file function is using to get record from random file<br />
Temp = CType(vt, PhoneList)<br />
FindLastRecordNo = FindLastRecordNo + 1<br />
Loop<br />
FileClose(FileNum)<br />
End Function<br />
<br />
<br />
Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click<br />
Dim Response As DialogResult<br />
Dim PhoneBook As PhoneList, LastRecord, I As Integer<br />
txtName.Text = StrConv(txtName.Text, VbStrConv.ProperCase)<br />
txtMiddle.Text = StrConv(txtMiddle.Text, VbStrConv.ProperCase)<br />
txtSurname.Text = StrConv(txtSurname.Text, VbStrConv.ProperCase)<br />
txtFirstLine.Text = StrConv(txtFirstLine.Text, VbStrConv.ProperCase)<br />
txtSecondLine.Text = StrConv(txtSecondLine.Text, VbStrConv.ProperCase)<br />
txtTown.Text = StrConv(txtTown.Text, VbStrConv.ProperCase)<br />
txtPostCode.Text = StrConv(txtPostCode.Text, VbStrConv.UpperCase)<br />
LastRecord = FindLastRecordNo() 'call last record function <br />
'Check if all three text boxes in tabpage add is not blank<br />
FileNumber = FreeFile()<br />
FileOpen(FileNumber, MyFile, OpenMode.Random, , , Len(PhoneBook))<br />
PhoneBook.Inits = cboInits.Text<br />
PhoneBook.Gender = cboGender.Text<br />
PhoneBook.FName = txtName.Text<br />
PhoneBook.MName = txtMiddle.Text<br />
PhoneBook.SName = txtSurname.Text<br />
PhoneBook.HomePhone = CStr(Val(txtHome.Text))<br />
PhoneBook.Mobile = CStr(Val(txtMobile.Text))<br />
PhoneBook.Email = CStr(Val(txtEmail.Text))<br />
PhoneBook.HouseNo = CStr(Val(txtHouse.Text))<br />
PhoneBook.FLine = txtFirstLine.Text<br />
PhoneBook.SLine = txtSecondLine.Text<br />
PhoneBook.Town = txtTown.Text<br />
PhoneBook.PostCode = txtPostCode.Text<br />
PhoneBook.Country = cboCountry.Text<br />
FilePut(FileNumber, PhoneBook, LastRecord)<br />
FileClose(FileNumber)<br />
MessageBox.Show("Item successfuly Saved", "Item Saved", MessageBoxButtons.OK, MessageBoxIcon.Information)<br />
End Sub<br />
End Class
but it's shows error that bad record length i have debug program several times but i can not understand what to do, in local windows it's shows few information like name, middle name,surname,home phone,mobile but rest is nothing but how can i solve this problem
can any body help me with this
waiting for your kind rep.
-- modified at 14:49 Sunday 16th September, 2007
|
|
|
|
|
Please only post the part of the code that is having trouble. You posted more than necessary.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hello sir
thanks for your rep.
i have modifid the code
so can you please tell me how to solve this problem
waiting for your kind rep.
thanks
|
|
|
|
|
What on earth are FileOpen, FilePut, etc ? Nasty VB6 legacy methods, or methods you wrote ?
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 )
|
|
|
|
|
Christian Graus wrote: FileOpen, FilePut, etc ? Nasty VB6 legacy methods
I vaguely remember seeing something hideous like that in the early VB days.
"Try asking what you want to know, rather than asking a question whose answer you know." - Christian Graus
|
|
|
|
|
first of all thanks all who sent their posts
and to be very honest i wanted to use VBFixedString and that time string was in my mind and i typed array and all problem starts
so this is very stupid mistake
but any way job done and problem sorted
thanks all again
|
|
|
|
|
sir
I need simple codings in .net .I am at beogners stage.
|
|
|
|
|
Sounds like you should be buying a book, working through it, then moving on to the articles on this site. No-one can post anything that is likely to help you at this point, in a forum reply.
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 )
|
|
|
|
|
Mahendhirans wrote: I need simple codings in .net
You've come to a site that has plenty of code samples, articles, etc. Post only if you have a specific question. Also, work on your English skills will get better when you engage in dialogue with people on this site.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
Need simple code in vb6 to convert a .txt file or string to a .wav file using a selected voice. I am new at this & can't seem to find any snippets anywhere.
Robert, still trying
|
|
|
|
|
Well, as you're new, why are you using VB6, a dead, unsupported and terrible language ? VB.NET is free.
What you're asking for is not simple, hence the lack of code snippets.
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 )
|
|
|
|
|
Christian Graus wrote: Well, as you're new, why are you using VB6, a dead, unsupported and terrible language ? VB.NET is free.
What you're asking for is not simple, hence the lack of code snippets.
Christian;
It's my understanding vb.NET will not run on Windows 98. Maybe it's time I upgrade??
Robert, still trying
|
|
|
|
|
don't know if that's true or not, but it's free, so it's worth trying.
Yes, it's definately time for a new OS.
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 )
|
|
|
|