我可以将VB代码转换为C ++吗? [英] CanI convert VB code to C++?

查看:117
本文介绍了我可以将VB代码转换为C ++吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将VB代码转换为C ++代码吗?
如何转换代码?

这是我的VB代码.

Can i convert VB code to C++ code??
How can i convert the code??

this is my VB code.

Dim OpenFileDialog1 As New OpenFileDialog

        With OpenFileDialog1
            .CheckFileExists = True
            .ShowReadOnly = False
            .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
            .FilterIndex = 2
            If .ShowDialog = DialogResult.OK Then
                ' Load the specified file into a PictureBox control.
                PictureBox1.Image = Image.FromFile(.FileName)
            End If
        End With

推荐答案

给出的示例是C ++/CLI.标准C ++会完全不同,但仍然微不足道.
The example you were given was C++/CLI. Standard C++ will be totally different, but still trivial.


是的.
而且不会困难.
:)
Yes you can.
And it won''t be difficult.
:)


简单示例:)
Simple example :)
FileStream* OpenFile()
   {
       // Displays an OpenFileDialog and shows the read/only files.

       OpenFileDialog* dlgOpenFile = new OpenFileDialog();
       dlgOpenFile->ShowReadOnly = true;

       if (dlgOpenFile->ShowDialog() == DialogResult::OK) {
           // If ReadOnlyChecked is true, uses the OpenFile method to
           // open the file with read/only access.
           if (dlgOpenFile->ReadOnlyChecked == true) {
               return dynamic_cast<FileStream*>(dlgOpenFile->OpenFile());
           }

           // Otherwise, opens the file with read/write access.
           else {
               String* path = dlgOpenFile->FileName;
               return new FileStream(path, System::IO::FileMode::Open,
                   System::IO::FileAccess::ReadWrite);
           }
       }
       return 0;
   }


这篇关于我可以将VB代码转换为C ++吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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