poojavb 29 Junior Poster

I debugged ur code....when the time u r entering a wrong value and u get an exception....
the second time if u enter some other value even if there is one match the input value is equal to 0 so it says no matches found....

poojavb 29 Junior Poster

What data do u want to show in ur report??? and based on which date....

poojavb 29 Junior Poster

Another approach is to validate the input string before performing the conversion using Java regular expression. I like that second approach because it is more elegant and it will keep your code clean.

public boolean isInteger( String input )   
{   
   try  
   {   
      Integer.parseInt( input );   
      return true;   
   }   
          catch( Exception )   
   {   
      return false;   
   }   
}  
poojavb 29 Junior Poster
Dim abc As String
    abc = TextBox4.Text
    If abc = "" Then
        MsgBox("Empty")
    Else
        If ListBox1.FindString(abc) <> True Then
            MsgBox("Got it")
        Else
            MsgBox("Not")
        End If
    End If
poojavb 29 Junior Poster

Did this help u???

poojavb 29 Junior Poster

Close the thread if its repeated....u have already closed the same thread....

poojavb 29 Junior Poster

While entering record in combo box make sure that it validates the count

Dim countvalue as Integer
countvalue=combobox1.Items.Count
if countvalue>60
Msgbox("Count cannot exceed 60")
else
'code to add the record in combobox
End If

Hope it helps u...

'Sorry I guess I did not understand the requirement....extremely sorry

poojavb 29 Junior Poster

The values in datagrid view will be entered manually or thru database ???
please explain in detail...

poojavb 29 Junior Poster

use this TextBoxDataKode.Text = DGS4.CurrentRow.Cell(0).Value.ToString() instead of TextBoxDataKode.Text = DGS4.Item(1, GridView.SelectedRows(0).Index).Value

poojavb 29 Junior Poster

if u are entering the datediff as years then it will show 1 yr as 2011 and 2012 has a diff of 1....

poojavb 29 Junior Poster

SO how do u want to display the date difference??? in months, year or days??? whatever parameter u will give in the date diff function it will be dependent on that....

poojavb 29 Junior Poster

if ur r using vb.net professional than see whether u have the crystal report installed in ur machine...then u will be able to get the crystal report viewer and will also be able to make the reports easily....

poojavb 29 Junior Poster

u can use the count function in the select query, if the count returns more than sixty values then prompt the message...

 Dim temp as Integer
 Try
    Dim myReader As OleDbDataReader
    Dim sql As String = "SELECT count(*) as total from tablename where Section='" + combobox1.Text + "'"
    Dim comm As OleDbCommand = New OleDbCommand(sql, Connection)
    Debug.Print("Query: " + comm.CommandText)
    myReader = comm.ExecuteReader
    While myReader.Read()
        temp = myReader.Item("total")
    End While
    If temp > 60 Then
        MsgBox("Exceeding limit")
    End If
    myReader.Close()
Catch ex As Exception
    MsgBox(ex.Message)
End Try
poojavb 29 Junior Poster

try using Date.Today instead of using My.Computer.Clock.LocalTime.Date

poojavb 29 Junior Poster

try using Date.Today instead of using My.Computer.Clock.LocalTime.Date

poojavb 29 Junior Poster

u can have a select query where the username will be the one from the login screen...according to the username get the firstname and the last name and display it on the screen....this can be done in the Login button...

while validating the login u can write as below....

select firstname, lastname, password from tablename where username ='" +Textbox1.Text+"'"

in this way u will get the firstname and lastname as well....

so first validate the password and then move the firstname and lastname in some variable and then show that variable on form 2 as soon as login is validated...

Dim fname as String
Dim lname as String

and then let the reader read the value

like

fname=reader("firstname")
lname=reader("lastname")
form2.txtName.Text = fname + lname 'this will show the variable on form2
Form2.show()
poojavb 29 Junior Poster

instead of & use + sign.....if still it does not work then try to convert SelectedItem.ToString to Text....hope it works for u...

poojavb 29 Junior Poster

instead of & use + sign.....if still it does not work then try to convert SelectedItem.ToString to Text....hope it works for u...

poojavb 29 Junior Poster

U can use Debug.Print("text: "+ text) to check the value...if u dont know how to use debugger

it will show the value of the word declared as a variable but it should be string else convert it to String...

Try this below code...

Private Sub ComboBox3_SelectedIndexChanged(sender As System.Object, e As System.EventArgs)
con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
Dim ewaaa As String = "SELECT * FROM Schedulings WHERE YearLevels = '" & ComboBox3.SelectedItem.ToString() & "' AND Sections = '" & ComboBox1.SelectedItem.ToString() & "'"
com = New OleDbCommand(ewaaa, con)
con.Open()
rid = com.ExecuteReader()
If rid.Read = True Then
MsgBox("Section Already Exist", MsgBoxStyle.Critical, "Error");
else
MsgBox("Section does not Exist", MsgBoxStyle.Critical, "Error");
End If
End Sub
poojavb 29 Junior Poster

U can use Debug.Print("text: "+ text) to check the value...if u dont know how to use debugger

it will show the value of the word declared as a variable but it should be string else convert it to String...

Try this below code...

  Private Sub ComboBox3_SelectedIndexChanged(sender As System.Object, e As System.EventArgs)

con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")

Dim ewaaa As String = "SELECT * FROM Schedulings WHERE YearLevels = '" & ComboBox3.SelectedItem.ToString() & "' AND Sections = '" & ComboBox1.SelectedItem.ToString() & "'"
com = New OleDbCommand(ewaaa, con)
con.Open()
rid = com.ExecuteReader()
    If rid.Read = True Then
       MsgBox("Section Already Exist", MsgBoxStyle.Critical, "Error");
       else
       MsgBox("Section does not Exist", MsgBoxStyle.Critical, "Error");
    End If
End Sub
poojavb 29 Junior Poster

Remove that if (If ComboBox3.Text = "'") condition y u need it???

and u have written double quotes then single quote and then double quotes in the if condition for combobox text....y u need that??? remove the single quote and keep it just If ComboBox3.Text = "" Then....i would recommend to remove that condition

anyways if this is the condition it wont enter the if loop anytime...

poojavb 29 Junior Poster

Remove that if (If ComboBox3.Text = "'") condition y u need it???

and u have written double quotes then single quote and then double quotes in the if condition for combobox text....y u need that??? remove the single quote and keep it just If ComboBox3.Text = "" Then....i would recommend to remove that condition

anyways if this is the condition it wont enter the if loop anytime...

poojavb 29 Junior Poster

use this TextBoxDataKode.Text = DGS4.CurrentRow.Cell(0).Value instead of TextBoxDataKode.Text = DGS4.Item(1, GridView.SelectedRows(0).Index).Value

poojavb 29 Junior Poster

paste ur code again so that we can help u....if already fixed mark the thread as solved....
Remove the if condition of validating...see if com is declared....check the connections

poojavb 29 Junior Poster

Use a list box instead of list view

before the code clear the list box every time else the value will be repeated...

use a distinct function in ur select query if the query is returning duplicate values

after the executer use a debug.Print("Query: "+ acscmd.CommandText) it will help u to understand the query

With ListBox1
            .DataSource = ds.Tables("TableName")
            .DisplayMember = "ColumnName"


        End With
poojavb 29 Junior Poster

darthswift00 - I guess for select query u should write ExecuteQuery() and not ExecuteNonQuery()

poojavb 29 Junior Poster

Whenever u write a coding for Database connection use the try catch block

Try

' *ur complete code goes here * 

Catch ex as Exception
MsgBox(ex.Message) ' if u get an error in above coding it will be passed to catch block and will display the error
End try
poojavb 29 Junior Poster

I have done this thing...chec below if it helps u

'Path1 is a string variable declared globally


 Dim di As DirectoryInfo = New DirectoryInfo(Application.StartupPath & "\Images\" + patientname + Date.Today.ToString("yyyy.MM.dd")) --- checked if a directory exists
 If Not di.Exists Then 'if no create the directory
     di.Create()
     Dim fileLoc As String = Application.StartupPath & "\Images\" + patientname + Date.Today.ToString("yyyy.MM.dd") + "\PatientRegEntry.txt"
     FileOpen(1, fileLoc, OpenMode.Output)
     Path1 = txtPatientID.Text + "*" + patientname + "*" + txtFName.Text + "*" + MName + "*" + LName + "*" + Age + "*" + Gender + "*" + Address + "*" + PhoneNo + "*" + MobNo + "*" + ReasonCurr + "*" + DenHist + "*" + DOB + "*" + ImagePath + "*" + DocName
     Print(1, Path1)
     FileClose()
End If
poojavb 29 Junior Poster

dont use the earlier if condition

use the below select query

"Select * from SchedulingTwos where YearLevels = '" & ComboBox1.Text & "'" and Sections = '" & ComboBox3.Text & '""

if this condition is true then u will get the alert message that the section is already added

    Private Sub ComboBox3_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ComboBox3.Validating
   ' If ComboBox3.Validating Then
    con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
    Dim ewaaa As String = "Select * from SchedulingTwos where YearLevels = '" & ComboBox1.Text & "'" and Sections = '" & ComboBox3.Text & "'"
    com = New OleDbCommand(ewaaa, con)
    con.Open()
    rid = com.ExecuteReader
    if rid.reader=true Then
    ' ComboBox3.Text = rid(2)
    MsgBox("Section Already Exist", MsgBoxStyle.Critical, "Error")
    ComboBox3.SelectedIndex = -1
    End If
  '  End If
    End Sub
poojavb 29 Junior Poster

use the below select query

"Select * from SchedulingTwos where YearLevels = '" & ComboBox1.Text & "'" and Sections = '" & ComboBox3.Text & '""

if this condition is true then u will get the alert message that the section is already added

poojavb 29 Junior Poster

Y use a variable??? u could have also done without a variable...just suggested...

TextBox9.Text = login.LevelofAccessTextBox.Text
poojavb 29 Junior Poster

What does ur combobox1 contains and what is in combobox3

Private Sub ComboBox3_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ComboBox3.Validating
    If ComboBox3.Validating Then
    con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
    Dim ewaaa As String = "Select * from SchedulingTwos where YearLevels = '" & ComboBox1.Text & "'"
    com = New OleDbCommand(ewaaa, con)
    con.Open()
    rid = com.ExecuteReader
        if rid.Read=True then
                MsgBox("Section Already Exist", MsgBoxStyle.Critical, "Error")
                ComboBox3.SelectedIndex = -1
        End If
    End If
End Sub
poojavb 29 Junior Poster

Mitja - Actually I tried without using ToSTring() funtion but I did not get the compiletime error....

It worked properly for me....so pasted without ToSTring() :)

poojavb 29 Junior Poster

try the below one

    Private Sub ComboBox3_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ComboBox3.Validating
        If ComboBox3.Validating Then
            con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
             Dim ewaaa As String = "Select * from SchedulingTwos where YearLevels = '" & ComboBox1.Text & "'"
             com = New OleDbCommand(ewaaa, con)
             con.Open()
             rid = com.ExecuteReader
            if rid.reader=true Then
               ' ComboBox3.Text = rid(2)
                MsgBox("Section Already Exist", MsgBoxStyle.Critical, "Error")
                ComboBox3.SelectedIndex = -1
            End If
        End If
    End Sub
poojavb 29 Junior Poster

if ur format is MMM-yyyy then u will get the output correctly....but the date will be wrong...it will be the first of the month...

poojavb 29 Junior Poster

Just make sure that the cell value u are entering in the code is correct...u can write the code in the datagridview cellclick event ...
as and when u click on the datagridview cell the value will be displayed in ur textbox

poojavb 29 Junior Poster

Enter the correct cell no and then on the click of the row in datagrid view u will get the cell value in the text box

textbox1.Text = DGS4.CurrentRow.Cells(0).Value
poojavb 29 Junior Poster

this code shud be written

SELECT td.num,SUM(td.cost) AS Total,tp.prize FROM tblData td, tblPrize tp WHERE td.num = tp.num GROUP BY td.num, tp.Prize
poojavb 29 Junior Poster

u can use the below code

this code shud be written in form1 where u will redirect it to form2

form2.txtName.Text = txtUsername.Text
Form2.show()

else u can use the below code in ur form2 load event

txtName.Text = form1.txtUsername.Text
poojavb 29 Junior Poster

else u can one create a integer variable and set the integer variable to

Dim abc as Integer
abc = Date.Today.Year.ToString * 10000 + 1

in ur insert query use the abc variable and the next time u want to use it increment the same by 1....

poojavb 29 Junior Poster

In ur insert query u can use the following to get the date....

Date.Today.Year.ToString

and then concatenate the remaining value to the string

poojavb 29 Junior Poster

Actually the bill is a ,edical prescription and it will contain more than 1 row for the same transaction....
how will I save all the data in one row itself....
coz I was thinking to add the receipt number to that transaction and store the values in a different database...
and then call the data using joins

poojavb 29 Junior Poster

Hello Friends,

I need idea for my below process...

I have one medical prescription form in my table....which will generate bill...and a receipt number will be generated in crystal reports....

If suppose a bill is generated for a particular transaction and after suppose few days i need a duplicate bill....how can it be created...means how shud I store the values for all bill generated in the past...

poojavb 29 Junior Poster

Hello Friends,

I need one help
I have a datetimepicker control, a combobox with day i.e. Sunday, Monday and so on....
The datetimepicker min date will be todays date and max date will be more 7 days...i.e. a week...

so the days dont get repeated..means sunday will come only one and so the remaining days also...

I want that when the user will select sunday from combo box the value in the datetime picker shud be set to sunday...

is this possible...please help me...

poojavb 29 Junior Poster

Hello Friends,

I want a small help...

I have created a text box....a button and a date time picker control

I have showed the calander control on click of the button event....when a value is selected in the datetimepicker the value should be showed in the text box...

I have done this....in the datetimepicker value change event

But then I want that the datetimepicker control to hide again...but this code I cant write in the value change event since if I write the hide code in datetimepicker value change event it will hide it every time...

cant write in lost focus also since it will have to wait till the focus is lost

cant write the code in text box value change event since the value will be changed after every click in datetimepicker

I want to write the code when the value in calander is doubleclicked...can anyone help on this???

poojavb 29 Junior Poster

i cant get you pooja , what do you mean by instance , well if you just want to know is * is in text file ? please check this attachment.

Regards

Not able to open the file...i wanted to know how many times * exists in the file .... nyways I got the answer....

Dim abc As String = "abc*def*sjfsd*xdvx*"
                        Dim pattern As String = "\*"
                        Dim expr As New System.Text.RegularExpressions.Regex(pattern)
                        Dim m As System.Text.RegularExpressions.MatchCollection
                        m = expr.Matches(abc)
                        Debug.Print("m count: " + m.Count.ToString)
poojavb 29 Junior Poster

Hello Friends,

I want to calculate the instance of * in the text file....

but I am not able to do it....

can anyone tell me which file funtion to use for it...

I first tried to read the file --- its just one line file

then see if the character '*' exists in the file...

I am done till here...i dont to know to proceed further....

poojavb 29 Junior Poster

not really my point: you wanted to have an .exe and then you say: my .jar file can't do this.

well, they're not really related, are they? I just asked why you made it a .exe in the first place.

as to an answer, "the code can not be replaced"??? it's called upgrading. if you can't change the code, even if you 'fix' the current problem, you'll pretty soon have the same problem. providing your clients with an upgrade will be a lot less trouble than having to debug and trying to 'solve' the problem every time it occurs.

Thanks everyone but I solved my problem....

I created one file in vb.net that is working and solved my issue....

poojavb 29 Junior Poster

Hello friends....

I have to check the folder path in such a way that

c:\Pooja\dynamic_folder\Output.txt

From Pooja folder how will I be able to move to the text file since the dynamic folder can be anything and I want to move inside the dynamic folder...

is there any way...

i tried this

Dim path As String
        path = "C:\Pooja\Images\dynamic\PatientRegEntry.txt"
        Debug.Print("Path: " + path)

The above code got solved but I need to replace a particular string with another word...but the string is not showing any effect

Imports System.IO
Imports System.Text.RegularExpressions

Public Class frmOutput
    Dim path As String
    Private Sub frmOutput_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dig As DirectoryInfo = New DirectoryInfo("C:\Pooja\Images\")
        Dim number As Integer
        number = System.IO.Directory.GetDirectories(dig.ToString).Length
        ListBox1.Items.Clear()
        If number = 0 Then
            MsgBox("No files found")
        Else
            Dim di As New IO.DirectoryInfo("C:\Pooja\Images\")
            Dim diar1 As IO.DirectoryInfo() = di.GetDirectories()
            Dim dra As IO.DirectoryInfo
            For Each dra In diar1
                ' ListBox1.Items.Add(dra)
                Dim filename As FileInfo = New FileInfo("C:\Pooja\Images\" + dra.ToString + "\PatientRegEntry.txt")
                If dra.ToString <> "DataBackup" Then
                    If Not filename.Exists Then
                        Debug.Print("File absent: " + filename.ToString)
                    Else
                        Debug.Print("File present: " + filename.ToString)
                        Dim fName As String = "C:\Pooja\Images\" + dra.ToString + "\PatientRegEntry.txt"               'path to text file
                        Dim testTxt As New StreamReader(fName)
                        Dim allRead As String = testTxt.ReadToEnd()
                        Debug.Print("allRead: " + allRead)
                        Dim regMatch As String = "000Y"
                        If Regex.IsMatch(allRead, regMatch) Then
                            Debug.Print("In Loop")
                            allRead = Replace(allRead, "000Y", "empty")
                        Else
                            Debug.Print("Else Loop")
                        End If
                        ListBox1.Items.Add(dra)
                    End If
                Else
                    Debug.Print("DataBackup")
                End If
            Next
        End If
    End Sub …
poojavb 29 Junior Poster

Hello friends....

I have to check the folder path in such a way that

c:\Pooja\dynamic_folder\Output.txt

From Pooja folder how will I be able to move to the text file since the dynamic folder can be anything and I want to move inside the dynamic folder...

is there any way...

i tried this

Dim path As String
        path = "C:\Pooja\Images\dynamic\PatientRegEntry.txt"
        Debug.Print("Path: " + path)