Hi,
I'm new to Visual basic. I am currently writing a small program that stores a person's name and email address into a simple database. See code below - Module Code
-
-
Module Module1
-
Structure EmailDataBase
-
<VBFixedString(25)> Public name As String
-
<VBFixedString(50)> Public email As String
-
-
End Structure
-
-
Public EmailContact As EmailDataBase
-
-
Public Filename = "C:\database\email.dbf"
-
End Module
-
-
First Part - Input data into file
-
-
Public Class Form2
-
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
-
-
Dim NextRecord As Integer
-
Dim SearchName As String
-
Dim RecordLength As Integer
-
SearchName = TextBox1.Text
-
-
FileClose(1)
-
-
RecordLength = Len(EmailContact)
-
-
FileOpen(1, Filename, OpenMode.Random, OpenAccess.Default, OpenShare.Default, RecordLength)
-
-
If LOF(1) < 1 Then NextRecord = 1 Else NextRecord = LOF(1) / RecordLength + 1
-
-
EmailContact.name = TextBox1.Text
-
EmailContact.email = TextBox2.Text
-
-
FilePut(1, EmailContact, NextRecord)
-
-
Me.Close()
-
Form1.Close()
-
-
End Sub
-
End Class
-
-
Second Part - Find the email address by inputting Name
-
-
Public Class Form4
-
Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
-
-
End Sub
-
-
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
-
-
Dim SearchName As String
-
Dim SearchNameLower As String
-
Dim RecordLength As Integer = Len(EmailContact)
-
Dim RecordNo As Integer
-
-
'following variables store emailcontact variables as ToLower
-
-
Dim SearchEmail As String
-
Dim EmailName As String
-
-
SearchName = TextBox1.Text
-
SearchNameLower = SearchName.ToLower
-
-
FileClose(1)
-
-
FileOpen(1, Filename, OpenMode.Random, OpenAccess.Default, OpenShare.Default, RecordLength)
-
-
RecordNo = LOF(1) / Len(EmailContact)
-
-
For x = 1 To RecordNo
-
-
'If x > 1 Then x = x - 1
-
-
FileGet(1, EmailContact, x)
-
-
SearchEmail = (EmailContact.email.ToLower)
-
EmailName = EmailContact.name.ToLower
-
-
If SearchNameLower = EmailName Then
-
MsgBox("Match")
-
Else
-
MsgBox("No Match")
-
End If
-
-
Next x
-
-
-
-
End Sub
-
End Class
-
-
The problem I am having issues with is in relation to matching the name to the email address in my small database file. When I try and match the name input from textbox1 against the name in the database, the search function is not displaying correctly whether the match is correct or not. I hope this makes sense.
Ive tried to google the answer, use StrComp, String.Equal and String.Compare with no luck.
Any ideas gratefully received
Thanks in advance
0 3026 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt |
last post by:
if (123 > 33) will return true
and
if ("123" > 33) will return true
So my question is, if the above behaviors are the same?? If string is
a number, and
compare with another number, it will...
|
by: tvn007 |
last post by:
#include <iostream>
#include <string>
int main (void){
using namespace std;
string STR =("TEST");
const std::string::size_type STR_SIZE = STR.size();
int count =0;
while ( count <=...
|
by: Leo Nunez |
last post by:
Hello!
I need copy from structure "A" to "B" that contains "strings" in a one line code.
Me problem like this :
typedef struct tHeader{
char field1;
char field2;
char field3;
|
by: Kiran B. |
last post by:
Hi, I am new to .net. I have two Data Structure Type ... Sturcture A and
Structure B.
Structure A
Public Fname as String
Public LastName as String
Public City as String
Public Zip as String...
|
by: Soujiro |
last post by:
typedef struct
{
int age;
string name;
} structure;
int functionCall( map< char* , structure* >* map_o )
{
map< char* , structure* >* map_op;
map_op = map_o;
|
by: lovecreatesbea... |
last post by:
Is it correct and safe to compare a string object with "", a pair of
quotation marks quoted empty string?If the string object: s = ""; does
s contain a single '\'? Is it better to use...
|
by: swapnilladhe |
last post by:
Hi,
I have a array of string and a variable containing string and i code like as;
if(String.compare(DFArray,checkBox.name)==0) {
alert("R U HERE?");
f=false;
...
|
by: pureenhanoi |
last post by:
Hi bro!
Can anyone tell me, how to compare two strings like Operating System compare file names.
Example: if i have two string "T*.DOC" and "TIET1.DOC". The comparision operator must return TRUE...
|
by: ndoe |
last post by:
how to compare string in file i mean compare that string content digit or alphabet,and 1 question more can we count that line if first line variable = 1,if read second line variable = 2 and so on...
|
by: Kilavo |
last post by:
I'm developing a system which I want to locate different places. Have the database which contain some Latitude and longitude and want to compare with the one received from the GPS through GSM modem...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |