从C到VB.net [英] C to VB.net

查看:89
本文介绍了从C到VB.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有人知道如何将C转换为Visual Basic.net.我有一些旧代码要在新的Windows窗体中使用,有人可以帮忙转换我的代码吗?

Does anyone know how to convert C to Visual Basic.net. I have some old code that I want to use in a newer windows form can someone help convert my code???

//Caesar encryptor program
#include <stdio.h>
#include "sys\stat.h"

int main()
{
    int data, output;
    long long int count=0;
    struct stat statbuf;
    char enc_file[260], dec_file[260];
    int shift_phase;
    FILE * sourcefile;
    FILE * destfile;


    printf("\nShift phase: ");
    scanf("%d", &shift_phase);
    printf("\nFile path of target file: ");
    scanf("%s", enc_file);
    printf("\nOutput File Path: ");
    scanf("%s", dec_file);

    if ((sourcefile = fopen(enc_file, "rb"))== NULL)
    {
        printf("\nCan't open target file %s.\n", enc_file);
        return(4);
    }

    fflush(sourcefile);
    fstat(fileno(sourcefile), &statbuf);
    fclose(sourcefile);


    if ((sourcefile = fopen(enc_file, "rb")) == NULL)
    {
        printf("\nCan't open target file %s \n", enc_file);
        return(4);
    }

    if ((destfile=fopen(dec_file,"wb")) == NULL)
    {
        printf("\nCan't open destination file %s \n", dec_file);
        return(4);
    }


    while (count < (statbuf.st_size))
    {
        data=fgetc(sourcefile);
        output=(data+shift_phase);
        fputc(output,destfile);
        count++;
    }

    fclose(sourcefile);
    fclose(destfile);

    return 0;

}

推荐答案

好吧,C代码实际上很简单,我想您可以用少于10的方式编写等效的VB.NET方法分钟.
:)
Well, the C code is actually simple, I guess you may write an equivalent VB.NET method in less than 10 minutes.
:)


当然,很多人都可以帮助您转换代码,但是(除非您很幸运),您不会让某人免费这样做.

尝试租用编码器 [ http ://www.codeproject.com/script/Jobs/Edit.aspx [ ^ ]
Sure, a lot of people could help you convert your code, but (unless you''re lucky) you''re not going to get someone to do it for free.

Try Rent A Coder[^] or http://www.codeproject.com/script/Jobs/Edit.aspx[^]


说实话,这是非常简单的C代码...它基本上只是文件io,但输入有所变化数据.您应该能够使用System.IO命名空间来完成所有这些工作.只是google VB .NET文件IO

您只需要一个转移阶段,一个输入文件和一个输出文件.

然后,打开文件,获取文件大小,然后从源中逐字符读取字符,将字符移位并输出到输出文件.

这些都是非常基本的文件IO,并且可以通过Google轻松找到.如果您的问题是您不了解C代码,则需要对其进行研究.使用google非常容易.

如果您不懂.Net,则需要购买一些书籍并仔细阅读.
To be truthful, that is pretty simple c code...it''s basically just file io with a shift of the input data. You should be able to do all of that with the System.IO namespace. Just google VB .NET File IO

You just ask for a shift phase, an input file, and an output file.

Then, you open the files, get the file size and go character by character reading from the source, shifting the character and outputting to the output file.

It''s all very basic File IO and pretty easy to find with google. If your problem is that you don''t understand the C code, then you need to research it. It''s pretty easy to do with google.

If you don''t understand .Net, then you need to buy some books and read up on it.


这篇关于从C到VB.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆