V9 - Convert from VB to C# Import Accounting Records

Asked

Viewed 93 times

-4

Good morning,

I’m trying to convert a program I did from VB to c#. I’m having a hard time with the headline. In Vb is simple.

Dim Doc As New CblBEDocumento
Dim Mov As CblBELinhaDocGeral
Doc.Ano = 2010

etc. In C# summarized

CblBEDocumento CblDoc = new CblBEDocumento();
CblBELinhaDocGeral MovCbl = new CblBELinhaDocGeral();
resultado = Plataforma.Consulta("Select `from " + tab_tmp + " order by ano, mes ASC");
if (resultado.Vazia())
 {
 Printa("Não tem movimentos de contabilidade para processar!");
  }
else
{
while (!resultado.NoFim())
{
Ano = resultado.Valor("Ano");
Mes = resultado.Valor("Mes");
Dia = resultado.Valor("Dia");
Data_Mov = resultado.Valor("Data_Mov");
Conta_Mov = resultado.Valor("Conta_Mov");
Descritivo = resultado.Valor("Descricao");
Diario = resultado.Valor("Diario");
Debito = resultado.Valor("Val_Deb");
Credito = resultado.Valor("Val_Cred");
CblDoc.set_Ano(Ano);

But when I try to do the CblDoc.Ano = '2010'; He doesn’t recognize the existence of Cbldoc.ano. I don’t have the option of tampering with the object’s field. Cbldoc.set_Ano expects a reference, I do not think it is like this. How do you use this object in C#? Thank you,

José Rui

  • 1

    Hello are you trying to convert VB.net to C#? It also helps to put more details in the question, more details increases the likelihood of getting desired help.

  • https://docs.microsoft.com/pt-br/dotnet/csharp/programming-guide/classes-and-structs/objects

  • Strange even is the assignment in single quotes, there are double quotes!

2 answers

0


Hello, I think you’re referring to the V9 where you use the interops. The allocation of values in this case is as follows::

CblDoc.set_Ano(2019);
  • Good morning, Yes, I was talking about the interops. I tried to use set_Ano, but he was not accepting the value I put there. I will test this assignment.

0

Your properties are public ?

example :

public class CblBEDocumento { 
       public string ano { get; set;} 
 }
  • It may be my mistake, but since the object is predefined and not by me, I usually don’t touch its properties

  • I understand, but you need to know if these properties are public, or if they have the get’s and set’s of the class. Without this information we cannot help you.

  • That’s my main problem, I’m still migrating and I still don’t think c# or fully Oop, so sometimes the installation doesn’t enter my hull.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.