| | |
Case Sensitivity
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 77
Reputation:
Solved Threads: 0
Please help me how to ignore case sensitivity in VB. My program is to store data in the database, though I use small letters or big letters, the database store the data starting with a capital letter followed by small letters. Ex.
Input: Neil, neil, NEIL
In the database: Neil
So if I input Neil, the program response is ok but if I input neil or NEIL, the program results an error in the database and the program exits.
Please I need your kind help. Thank you so much.
Regards,
Neil
Input: Neil, neil, NEIL
In the database: Neil
So if I input Neil, the program response is ok but if I input neil or NEIL, the program results an error in the database and the program exits.
Please I need your kind help. Thank you so much.
Regards,
Neil
hi, try this subroutine.. and use the final data to process to your database...
hope it helps...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Sub zz() Dim inputx, inputy, inputz, inputfinal As String Dim i As Integer inputx = InputBox("enter data") i = Len(inputx) inputy = UCase(Mid(inputx, 1, 1)) inputz = LCase(Mid(inputx, 2, i - 1)) inputfinal = inputy + inputz MsgBox inputfinal 'use inputfinal data to process to your database End Sub
hope it helps...
Last edited by cguan_77; Jan 23rd, 2009 at 2:04 am.
•
•
Join Date: Aug 2008
Posts: 77
Reputation:
Solved Threads: 0
Here is my sample code fragment, are there anything to be added in this code? please help me. . .thank you so much. . .
The highlight part is where the upper case and lower case error.
The highlight part is where the upper case and lower case error.
Private Sub cmdAdd_Click()
chec:
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = Con
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open "event"
End With
If rst.AbsolutePosition > -1 Then
rst.MoveLast
R_Count = rst.RecordCount
rst.MoveFirst
For i = 1 To R_Count
If rst.Fields("eventname") = Trim(txtEName.Text) Then
Label20.Caption = "Event Name Already Exist. Type a new one"
txtEName.SetFocus
Exit Sub
End If
rst.MoveNext
Next i
Call dataupdate2
Else
Call dataupdate2
End If
rst.Close
Set rst = Nothing
Call dload2
End Sub Last edited by Narue; Jan 23rd, 2009 at 11:33 am. Reason: added code tags
•
•
Join Date: Aug 2008
Posts: 77
Reputation:
Solved Threads: 0
If the name already exits in the database, the message "Event Name Already Exist. Type a new one" will supposedly appear. But it only works if I input "Neil" but if I input "neil" or "NEIL", error message appear, "you can't store item because it's already exist in the database" then the 3 buttons appear "end, debug and the 3rd one (i forgot the name) will appear. What do you think is wrong with the code? Why is it this message (Event Name Already Exist. Type a new one) will not appear if I input the same name but with different letter case?
All I want is no matter what case you use, the message "Event Name Already Exist. Type a new one" should appear if it exist in the database. . .help me, thank you so much.
All I want is no matter what case you use, the message "Event Name Already Exist. Type a new one" should appear if it exist in the database. . .help me, thank you so much.
•
•
•
•
If the name already exits in the database, the message "Event Name Already Exist. Type a new one" will supposedly appear. But it only works if I input "Neil" but if I input "neil" or "NEIL", error message appear, "you can't store item because it's already exist in the database" then the 3 buttons appear "end, debug and the 3rd one (i forgot the name) will appear. What do you think is wrong with the code? Why is it this message (Event Name Already Exist. Type a new one) will not appear if I input the same name but with different letter case?
All I want is no matter what case you use, the message "Event Name Already Exist. Type a new one" should appear if it exist in the database. . .help me, thank you so much.
just write a private function with return type of boolean, pass the event name which you need to check for duplication as parameter
now on a button_click event, accept an event name from a textbox, call the function and if it returns true then show your msg....that's it....so simple...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Function IsEventExists(ByVal evtName As String) As Boolean Dim gcn As New ADODB.Connection Dim rs As New ADODB.Recordset On Error GoTo err1 If gcn.State = adStateOpen Then gcn.Close Set gcn = Nothing gcn.ConnectionString = "<your connection string>" gcn.Open rs.CursorLocation = adUseClient rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic rs.Open "select * from <your tablename> where <your field name>='" & Trim(evtName) & "'", gcn If rs.RecordCount > 0 Then IsEventExists = True Else IsEventExists = False End If If rs.State = adStateOpen Then rs.Close Set rs = Nothing Exit Function err1: Err.Clear IsEventExists = True Exit Function End Function Private Sub Command1_Click() If IsEventExists(Text1.Text) = True Then MsgBox "Event Name Already Exist. Type a new one", vbInformation, "Duplicate Event" Text1.SetFocus Else '''insert it to the database...put the code here End If End Sub
get me a feed if this works out for you...
regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
•
•
Join Date: Aug 2008
Posts: 77
Reputation:
Solved Threads: 0
This is what I did:
-------------------------------------------------------------------------------------
OUTPUT: "Event Name Already Exist. Type a new one" this messge always pop-up even I put a new event name. what do you think is wrong with my code?
The "dload2" there is where the data display in the MSFlexGrid. What am I going to put in the "gcn.ConnectionString="<?>"?
Private Function IsEventExists(ByVal evtName As String) As Boolean
Dim gcn As New ADODB.Connection
Dim rst As New ADODB.Recordset
On Error GoTo err1
If gcn.State = adStateOpen Then gcn.Close
Set gcn = Nothing
gcn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\facility.mdb"
gcn.Open
rst.CursorLocation = adUseClient
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open "select * from event where eventname='" & Trim(txtEName) & "'", gcn
If rst.RecordCount > 0 Then
IsEventExists = True
Else
IsEventExists = False
End If
If rst.State = adStateOpen Then rst.Close
Set rst = Nothing
Exit Function
err1:
Err.Clear
IsEventExists = True
Exit Function
End Function-------------------------------------------------------------------------------------
Private Sub cmdAdd_Click()
chec:
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = Con
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open "event"
End With
If IsEventExists(txtEName.Text) = True Then
MsgBox "Event Name Already Exist. Type a new one", vbInformation, "Duplicate Event"
txtEName.SetFocus
Else
With rst
.AddNew
.Fields!fnumber = StrConv(txtFNumber, vbProperCase)
.Fields!eventname = StrConv(txtEName, vbProperCase)
.Fields!fname = StrConv(txtFName, vbProperCase)
.Fields!fincharge = StrConv(txtFIncharge, vbProperCase)
.Fields!fschedules = StrConv(Text2, vbProperCase)
.Fields!fschedulee = StrConv(Text3, vbProperCase)
.Fields!sitcapacity = StrConv(txtCapacity, vbProperCase)
.Fields!userschede = StrConv(Combo4, vbProperCase)
.Fields!userscheds = StrConv(Combo3, vbProperCase)
.Fields!fuser = StrConv(txtFUser, vbProperCase)
.Fields!destination = StrConv(txtDestination, vbProperCase)
.Fields!condition = StrConv(cboCondition, vbProperCase)
.Fields!enddate = dtpDate(0).Value
.Fields!startdate = dtpDate(0).Value
.Fields!transaction = StrConv(cboTransaction, vbProperCase)
.Fields!fsh = StrConv(txtfsh, vbProperCase)
.Fields!ush = StrConv(txtush, vbProperCase)
.Update
Label20.Caption = "Successfully Saved. . ."
End With
End If
Call dload2
End SubOUTPUT: "Event Name Already Exist. Type a new one" this messge always pop-up even I put a new event name. what do you think is wrong with my code?
The "dload2" there is where the data display in the MSFlexGrid. What am I going to put in the "gcn.ConnectionString="<?>"?
Last edited by nagatron; Jan 24th, 2009 at 9:13 am.
![]() |
Similar Threads
- getting around case sensitivity. (C++)
- check case sensitive in login page (VB.NET)
- Open In New Window Php (PHP)
- website designed using PHP is case sensitive (Site Layout and Usability)
- C++ Identifiers and Keywords (C++)
- Is Select Case statement case sensitive in VB6? (Visual Basic 4 / 5 / 6)
- Windows 2000 startup probs (Windows NT / 2000 / XP)
- How to develop a new program (C++)
- We've Gone PHP! (DaniWeb Community Feedback)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: How To Append Record In Flexgrid Control ( if any)
- Next Thread: Reservation System Help using VB 6
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






