RonalBertogi 46 Junior Poster in Training

@histrungalot

Your code is fine and it sure will solve Major Aly's problem. But your code has limitations and can initiate memory leak errors since your AVGPCT* CALC(student *A) function assumes that *A* is an array of five. What if student is a pointer to an array of less than 5 students?

To make the code dynamic, write it this way:

AVGPCT* CALC(student *A, int cStudents)
{
   int x,y;
   //---------------------------------------
   // Have to allocate the memory here
   AVGPCT *D = new AVGPCT[cStudents];
   for(x=0;x<cStudents;x++)
   {
      D[x].avg = 0;
      D[x].pct = 0;
      for(y=0;y<3;y++)
      {
        D[x].avg+=A[x].SUB[y];
         D[x].pct+=A[x].SUB[y];
      }
   }
   for(x=0;x<cStudents;x++)
   {
      //---------------------------------
      //   I changed the value here to 3
      //   because there are 3 grades
      D[x].avg/=3;
      D[x].pct/=300;
   }
   return (D);
}

And call it this way:

student S[5];
AVGPCT *D = CALC(S, 5);
...
RonalBertogi 46 Junior Poster in Training

@Fearless Hornet,

I tried your code in my own project and it worked without errors. Of course, I did export your functions from my dll and called them in my exe.

However, did you try to execute your code step by step? I suggest you do this if you haven't yet and try to temporarily comment out the following lines:

for (auto s : vowels)
{
    OutputLog(s.c_str());
}
std::cout << std::endl;
for (auto i : novowels)
{
    OutputLog(i.c_str());
}
RonalBertogi 46 Junior Poster in Training

You are exporting your functions the wrong way!!!

Based on your code...

The code used to call the function is:
std::vector<std::string> vowels, novowels;
std::string info("test snippet of data");
std::string tokens("aeiou ");
vowels = Editor::StringHandler::Split(info);
novowels = Editor::StringHandler::Split(info, tokens);

...the functions Editor::StringHandler::Split() and its overload is expected to return a value which type is std::vector<std::string>. You defined these functions correctly but you exported them with type void.

To correctly export these functions use this syntax: std::vector<std::string> DATAEDITING_API Split(...)

And...just a humble comment: I don't see any benefit in creating dll exports that are static members of a class. Why don't just export these functions by themselves without a class and/or namespace?

RonalBertogi 46 Junior Poster in Training

How did you export this function from your DLL?

RonalBertogi 46 Junior Poster in Training

Here's mine for your number validation

Function Validate_Number(ByRef PassNumber As String) As Boolean
    Static szValidNum As String
    If szValidNum = "" Then _
        szValidNum = "0123456789"

    Dim szNum As String
    Dim c As String * 1, i As Integer, ch As Integer
    Dim dots As Integer, pluses As Integer, minuses As Integer
    ' Create a local copy of the PassNumber
    szNum = PassNumber
    ch = Len(szNum)
    ' Trim trailing dots.
    ' A number of multiple dots is number if these dots are the end of the number.
    ' We must be considerate
    Do While 1
        If Right(szNum, 1) <> "." Then Exit Do
        ch = ch - 1
        szNum = Left(szNum, ch)
    Loop
    For i = 1 To ch
        c = Mid(szNum, i, 1)
        If 0 = InStr(1, szValidNum, c) Then
            Select Case c
                Case "+"
                    'Make sure positive sign exists before anything else
                    If i > 1 Then Exit Function
                    'Make sure we are the only sign in this number
                    If minuses Then Exit Function
                    pluses = pluses + 1
                    'Reject multiple pluses
                    If pluses = 2 Then Exit Function
                Case "-"
                    'Make sure negative sign exists before anything else
                    If i > 1 Then Exit Function
                    'Make sure we are the only sign in this number
                    If pluses Then Exit Function
                    minuses = minuses + 1
                    'Reject multiple pluses
                    If minuses = 2 Then Exit Function
                Case "."
                    dots = dots + 1
                    'Make sure we are the only dot in this decimal number
                    If dots = 2 Then Exit Function
                Case Else
                    'Hell we are not a number!!!
                    Exit Function
            End Select
        End If
    Next i
    ValidateNum = True
End Function
RonalBertogi 46 Junior Poster in Training

What do you mean connect? Run an exe from a web site or use an exe as a server side app?

RonalBertogi 46 Junior Poster in Training

How nice miLiel!!! You're from Manila and I'm here in Leyte sitting in front of my PC and we're talking like we are somewhere else. ja ja ja ja!!!

RonalBertogi 46 Junior Poster in Training

Query = "DELETE FROM census WHERE txtEnterID ='" & strId & "'"
Are you sure txtEnterID field exists in your census table? Query filter names must be existing fields in the database's tables. If it don't exist you will get this error. And more thing, data must match with the data type of that field. If it's a string then you would pass string data in single quotes. Numbers don't have and MUST not be enclosed in quotes.

To be sure, open your database and look at your table, in this case the census. Select the field/(s) that would contain the unique data and use them as your filters in your delete query.

RonalBertogi 46 Junior Poster in Training

BTW, where is your OutBuffer? How was it initialized and, if ever, modified later? This could be the culprit.
string subString_is = getcmd.substr(0,3);//Extract PM00 from txt Are you sure you got 'PM00' when you get a subtring which length is only 3?
InBuffer[14] = 0x0A ??? This will overwrite the 15th character of your InBuffer. Is this intended?
memcpy(&InBuffer[15],"\0",1) This is not necessary. InBuffer[15 would suffice. If you use strcpy, this line will not even be necessary.

-----------------------------------------

Hello, I did not want to make this a new post. I tried to edit my previous post but I didn't know how to update it, as in, I didn't find a way. :(

anukavi commented: got a temporary soln to it... thanks a lot for the post.. +0
RonalBertogi 46 Junior Poster in Training

Based on your code, you are expecting characters 'K' and 'L' that when met, you will copy two groups of character which lengths are 6 and 4, respectively. What if these conditions are not satisfied, do you have a handler to this?

One more thing, I suggest using strcpy than memcpy since the former automatically adds a terminating null character.

RonalBertogi 46 Junior Poster in Training

If you really have typed line 3 (in reference to nullptr's post) that way, it is sure to generate a compile-time error cannot convert parameter 1 from 'char' to 'void *'. But if you have typed it like line 2, I'm pretty sure you will get a 14.

RonalBertogi 46 Junior Poster in Training

@meLiel,

As what I've said in my previous post, you have to make sure that you have successfully established the connection to your database before doing any database operation (e. g. querying, udpating, deleteing, etc) thus the error.

Here is a simple procedure to do that:

Dim conDB As ADODB.Connection ' it is sometimes ideal to make this a global variable when
                              ' you will be just accessing a single database

In your startup procedure (either in Sub Main() or in your Form_Initialize() procedure) set this following code:

Set conDB = new ADODB.Connection
conDB.CursorLocation = adUseClient

'Be sure to handle errors properly in case they occur
On Error Goto abort_app
conDB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<<Your_Database_Path>>;Persist Security Info=False"
Exit Sub

abort_app:
    MsgBox "Error opening database"
    Unload Me

NOTE: Make appropriate modification in the previous code. Such code was in the context of the Form_Initialize event of your Visual Basic form.

Now that you hvae already made the connection, you can do whatever you want to your database. Of course, it will still depend on the features provided by the provider.

Now, to delete a record, it's just as simple as

DELETE FROM <<tablename>> WHERE <<fieldFilter>>='discardable'

What makes sure that you won't delete the records you don't want to is the filter. You can add more filters to narrow the selection of records you want to delete like this:

DELETE FROM myTable WHERE record1='invalidrecord' AND record2=0 AND IsIncorrect Is True

AndreRet commented: Thanx +12
RonalBertogi 46 Junior Poster in Training

The code below assumes that you have already established your database connection. To delete a particular record the code is:

con.Execute "DELETE FROM <<tablename>> WHERE <<fieldFilter>>='discardable'"

NOTES:

  1. fieldFilter is the name of field in the table where you are to delete records.
  2. fieldFilter can take different systax. It can be a string like in this example where single-quotes are mandatory. If it's a number then the quotes is not needed. If your fieldFilter is a boolean, the syntax should be this: <<fieldFilter Is True>>. When you specify your actual tablename and fieldFilter name, omit these << and these >>.
RonalBertogi 46 Junior Poster in Training

The code below assumes that you have already established your database connection. To delete a particular record the code is:

con.Execute "DELETE FROM <<tablename>> WHERE <<fieldFilter>>='discardable'"

NOTES:

  1. fieldFilter is the name of field in the table where you are to delete records.
  2. fieldFilter can take different systax. It can be a string like in this example where single-quotes are mandatory. If it's a number then the quotes is not needed. If your fieldFilter is a boolean, the syntax should be this: <<fieldFilter Is True>>. When you specify your actual tablename and fieldFilter name, omit these << and these >>.